Update '12/dragable.js'

master
barkaiavital 5 years ago
parent eb7b2f0c1e
commit 67ad9a9064

@ -18,11 +18,11 @@
if (e.type=="mousedown") { if (e.type=="mousedown") {
xOffset = e.clientX - rect.left; //clientX and getBoundingClientRect() both use viewable area adjusted when scrolling aka 'viewport' xOffset = e.clientX - rect.left; //clientX and getBoundingClientRect() both use viewable area adjusted when scrolling aka 'viewport'
yOffset = e.clientY - rect.top; yOffset = e.clientY - rect.top;
window.addEventListener('mousemove', dragObject, true); dragObj.addEventListener('mousemove', dragObject, true);
} else if(e.type=="touchstart") { } else if(e.type=="touchstart") {
xOffset = e.targetTouches[0].clientX - rect.left; xOffset = e.targetTouches[0].clientX - rect.left;
yOffset = e.targetTouches[0].clientY - rect.top; yOffset = e.targetTouches[0].clientY - rect.top;
window.addEventListener('touchmove', dragObject, true); dragObj.addEventListener('touchmove', dragObject, true);
} }
} }
@ -43,11 +43,11 @@
} }
/*End dragging*/ /*End dragging*/
document.onmouseup = function(e) { dragObj.onmouseup = function(e) {
if (dragObj) { if (dragObj) {
dragObj = null; dragObj = null;
window.removeEventListener('mousemove', dragObject, true); dragObj.removeEventListener('mousemove', dragObject, true);
window.removeEventListener('touchmove', dragObject, true); dragObj.removeEventListener('touchmove', dragObject, true);
} }
} }
} }
@ -82,11 +82,11 @@ makeDragable('#shell_03header', '#shell_03')
if (x.type=="mousedown") { if (x.type=="mousedown") {
xOffset2 = x.clientX - rect.left; //clientX and getBoundingClientRect() both use viewable area adjusted when scrolling aka 'viewport' xOffset2 = x.clientX - rect.left; //clientX and getBoundingClientRect() both use viewable area adjusted when scrolling aka 'viewport'
yOffset2 = x.clientY - rect.top; yOffset2 = x.clientY - rect.top;
window.addEventListener('mousemove', dragObject2, true); dragObj2.addEventListener('mousemove', dragObject2, true);
} else if(e.type=="touchstart") { } else if(e.type=="touchstart") {
xOffset2 = x.targetTouches[0].clientX - rect.left; xOffset2 = x.targetTouches[0].clientX - rect.left;
yOffset2 = x.targetTouches[0].clientY - rect.top; yOffset2 = x.targetTouches[0].clientY - rect.top;
window.addEventListener('touchmove', dragObject2, true); dragObj2.addEventListener('touchmove', dragObject2, true);
} }
} }
@ -107,11 +107,11 @@ makeDragable('#shell_03header', '#shell_03')
} }
/*End dragging*/ /*End dragging*/
document.onmouseup = function(x) { dragObj2.onmouseup = function(x) {
if (dragObj2) { if (dragObj2) {
dragObj2 = null; dragObj2 = null;
window.removeEventListener('mousemove', dragObject2, true); dragObj2.removeEventListener('mousemove', dragObject2, true);
window.removeEventListener('touchmove', dragObject2, true); dragObj2.removeEventListener('touchmove', dragObject2, true);
} }
} }
} }

Loading…
Cancel
Save