mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Merge pull request #107 from nicofrand/fixRefreshOnTouchmove
Fix refresh on touchmove
This commit is contained in:
commit
ba2773b127
1 changed files with 12 additions and 4 deletions
|
@ -90,9 +90,14 @@ Element.toggleClass = function(element, className) {
|
||||||
/* Add Event
|
/* Add Event
|
||||||
https://github.com/Darklg/JavaScriptUtilities/blob/master/assets/js/vanilla-js/libs/vanilla-events.js
|
https://github.com/Darklg/JavaScriptUtilities/blob/master/assets/js/vanilla-js/libs/vanilla-events.js
|
||||||
-------------------------- */
|
-------------------------- */
|
||||||
window.addEvent = function(el, eventName, callback) {
|
window.addEvent = function(el, eventName, callback, options) {
|
||||||
if (el.addEventListener) {
|
if (el.addEventListener) {
|
||||||
el.addEventListener(eventName, callback, false);
|
if (!options || typeof(options) !== "object") {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
options.capture = false;
|
||||||
|
el.addEventListener(eventName, callback, options);
|
||||||
}
|
}
|
||||||
else if (el.attachEvent) {
|
else if (el.attachEvent) {
|
||||||
el.attachEvent("on" + eventName, function(e) {
|
el.attachEvent("on" + eventName, function(e) {
|
||||||
|
@ -148,6 +153,9 @@ var dragg = function(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected !== null) {
|
if (selected !== null) {
|
||||||
|
if (e.type === "touchmove"){
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
dragged = true;
|
dragged = true;
|
||||||
selected.style.left = (x_pos - x_elem) + 'px';
|
selected.style.left = (x_pos - x_elem) + 'px';
|
||||||
selected.style.top = (y_pos - y_elem) + 'px';
|
selected.style.top = (y_pos - y_elem) + 'px';
|
||||||
|
@ -165,7 +173,7 @@ var dragg = function(id) {
|
||||||
|
|
||||||
// Will be called when user dragging an element
|
// Will be called when user dragging an element
|
||||||
window.addEvent(window, 'mousemove', _onMove);
|
window.addEvent(window, 'mousemove', _onMove);
|
||||||
window.addEvent(window, 'touchmove', _onMove);
|
window.addEvent(window, 'touchmove', _onMove, {passive: false});
|
||||||
|
|
||||||
// Destroy the object when we are done
|
// Destroy the object when we are done
|
||||||
window.addEvent(window, 'mouseup', _shutDrag);
|
window.addEvent(window, 'mouseup', _shutDrag);
|
||||||
|
|
Loading…
Reference in a new issue