// Disable scroll by spacebar
$(window).on('keydown', function (e) {
if (e.keyCode == 32) {
- $("#linkeditor-main").addClass('grab');
+ if ($this.zoom.zoom !== 1) {
+ $("#linkeditor-main").addClass('grab');
+ }
return false;
} else if (e.keyCode == 18) {
$("#linkeditor-main").addClass('duplicate');
});
$(document).on('mousedown', "#linkeditor-main", function (e) {
+ $this.setMouseCoordinates(e);
if ($(this).hasClass('duplicate')) {
$this.links.duplicateLinkClick();
return;
} else if ($(this).hasClass('grab') && $this.zoom.zoom > 1) {
- $this.zoomdragging = {
- x: e.pageX,
- y: e.pageY,
+ $this.zoom.zoomdragging = {
+ x: $this.mx,
+ y: $this.my,
scrollX: $("#linkeditor-canvas").scrollLeft(),
scrollY: $("#linkeditor-canvas").scrollTop()
};
});
$(window).on('mouseup', function (e) {
+ $this.setMouseCoordinates(e);
$this.zoom.mouseUp();
$this.rulers.mouseUp();
$this.links.mouseUp();
updateMousePosition: function (e) {
- this.mx = e.pageX;
- this.my = e.pageY;
+ if (e !== undefined) {
+ this.setMouseCoordinates(e);
+ }
this.rulers.updateMousePositionRulers();
this.rulers.moveRuler();
this.zoom.updateMousePosition();
},
+ setMouseCoordinates: function (e) {
+ this.mx = e.pageX;
+ this.my = e.pageY;
+ },
+
changePage: function (page) {
if (page === undefined) {
let h = window.location.hash;
this.zoomdragging = false;
$("#linkeditor-main").on('wheel', function (e) {
+ $this.linkeditor.setMouseCoordinates(e);
let delta = e.originalEvent.deltaY;
if (delta === 0) {
return true;
mouseUp: function () {
if (this.zoomdragging !== false) {
- this.moveZoomDrag(e);
+ this.moveZoomDrag();
}
this.resetZoomDrag();
},
this.resetZoomDrag();
}
if (this.zoomdragging !== false) {
- this.moveZoomDrag(e);
+ this.moveZoomDrag();
}
},
this.zoomdragging = false;
},
- moveZoomDrag: function (e) {
- let deltaX = e.pageX - this.zoomdragging.x;
- let deltaY = e.pageY - this.zoomdragging.y;
+ moveZoomDrag: function () {
+ let deltaX = this.linkeditor.mx - this.zoomdragging.x;
+ let deltaY = this.linkeditor.my - this.zoomdragging.y;
$("#linkeditor-canvas").scrollTo({
top: this.zoomdragging.scrollY - deltaY, left: this.zoomdragging.scrollX - deltaX
});