Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #27 from MapOnline/2.0.5-2
Browse files Browse the repository at this point in the history
2.0.5-2
  • Loading branch information
Kevin Richter authored Jul 27, 2016
2 parents 35092e5 + e818d5f commit 59195c8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
10 changes: 6 additions & 4 deletions app/js/classes/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ Level.prototype.load = function() {
* @returns {boolean} Is the cursor on the map?
*/
Level.prototype.isOn = function(x, y) {
var offset = main.globals.offset.get();

return (
x > main.globals.offset.get().x &&
x < this.size.width + main.globals.offset.get().x &&
y > main.globals.offset.get().y &&
y < this.size.height + main.globals.offset.get().y
x > offset.x &&
x < this.size.width + offset.x &&
y > offset.y &&
y < this.size.height + offset.y
);
};

Expand Down
2 changes: 1 addition & 1 deletion app/js/classes/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Popup.prototype.show = function(center) {
*/
Popup.prototype.onShowMobile = function(point) {
// Overwrite with popup specific code
return this.onShowDesktop();
return this.onShowDesktop(point);
};

/**
Expand Down
26 changes: 15 additions & 11 deletions app/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,24 @@ var events = {
*/
touchStart: function(e) {
e.preventDefault();
if(main.object.levels.getCurrent().isOn(e.touches[0].clientX, e.touches[0].clientY)) {
helpers.doubleTap();

var bRect = e.target.getBoundingClientRect();

if(main.object.levels.getCurrent().isOn(e.touches[0].clientX - bRect.left, e.touches[0].clientY - bRect.top, e.target)) {
main.globals.isDown = true;
helpers.doubleTap();

main.globals.dragPosition = { x: e.touches[0].clientX, y: e.touches[0].clientY };
main.globals.clickStart = { x: e.touches[0].clientX, y: e.touches[0].clientY };
}

// Pinch to zoom
if(e.touches.length == 2) {
main.globals.isScaling = true;
// main.object.context.save();
main.globals.startDistance = Math.sqrt(
(e.touches[0].pageX - e.touches[1].pageX) * (e.touches[0].pageX - e.touches[1].pageX) +
(e.touches[0].pageY - e.touches[1].pageY) * (e.touches[0].pageY - e.touches[1].pageY));
// Pinch to zoom
if(e.touches.length == 2) {
main.globals.isScaling = true;
// main.object.context.save();
main.globals.startDistance = Math.sqrt(
(e.touches[0].pageX - e.touches[1].pageX) * (e.touches[0].pageX - e.touches[1].pageX) +
(e.touches[0].pageY - e.touches[1].pageY) * (e.touches[0].pageY - e.touches[1].pageY));
}
}

// Android zoom
Expand Down Expand Up @@ -329,7 +333,7 @@ var events = {
* @param e - The event object
*/
dbltap: function(e) {
if(helpers.clickedInCanvas(e.target) && main.object.levels.isOn(main.globals.dragPosition.x, main.globals.dragPosition.y)) {
if(helpers.clickedInCanvas(e.target) && main.object.levels.getCurrent().isOn(main.globals.dragPosition.x, main.globals.dragPosition.y)) {
var levels = main.object.levels.getLevels([main.object.levels.current, main.object.levels.current + 1]);
if(levels[1] !== null) {
main.globals.offset.changeTo(
Expand Down

0 comments on commit 59195c8

Please sign in to comment.