mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-51803 core: fix for touchstart
This commit is contained in:
parent
e134ad7b38
commit
e3c2a1bb3a
2 changed files with 20 additions and 3 deletions
2
lib/amd/build/sortable_list.min.js
vendored
2
lib/amd/build/sortable_list.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,23 @@ function($, log, autoScroll, str, ModalFactory, ModalEvents, Notification) {
|
|||
overElementClass: 'sortable-list-over-element'
|
||||
};
|
||||
|
||||
/**
|
||||
* Allow to create non-passive touchstart listeners and prevent page scrolling when dragging
|
||||
* From: https://stackoverflow.com/a/48098097
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
$.event.special.touchstart = {
|
||||
setup: function(_, ns, handle) {
|
||||
if (ns.includes('notPassive')) {
|
||||
this.addEventListener('touchstart', handle, {passive: false});
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise sortable list.
|
||||
*
|
||||
|
@ -111,10 +128,10 @@ function($, log, autoScroll, str, ModalFactory, ModalEvents, Notification) {
|
|||
}
|
||||
if (typeof this.config.listSelector === 'object') {
|
||||
// The root is an element on the page. Register a listener for this element.
|
||||
$(this.config.listSelector).on('mousedown touchstart', $.proxy(this.dragStartHandler, this));
|
||||
$(this.config.listSelector).on('mousedown touchstart.notPassive', $.proxy(this.dragStartHandler, this));
|
||||
} else {
|
||||
// The root is a CSS selector. Register a listener that picks up the element dynamically.
|
||||
$('body').on('mousedown touchstart', this.config.listSelector, $.proxy(this.dragStartHandler, this));
|
||||
$('body').on('mousedown touchstart.notPassive', this.config.listSelector, $.proxy(this.dragStartHandler, this));
|
||||
}
|
||||
if (this.config.moveHandlerSelector !== null) {
|
||||
$('body').on('click keypress', this.config.moveHandlerSelector, $.proxy(this.clickHandler, this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue