MDL-62319 Assign: Grading interface is broken when using iOS 11.3 devices

This commit is contained in:
Nathan Nguyen 2018-08-20 12:56:34 +10:00 committed by Damyon Wiese
parent 129783b98c
commit 923641f71c
5 changed files with 219 additions and 7 deletions

View File

@ -35,6 +35,7 @@
position: absolute;
overflow: auto;
background-color: #ccc;
touch-action: none;
}
.assignfeedback_editpdf_widget {

View File

@ -3500,6 +3500,14 @@ EDITOR.prototype = {
*/
collapsecomments: true,
/**
* Check if passive option is supported
* @property isPassiveSupported
* @type Boolean
* @public
*/
isPassiveSupported : false,
/**
* Called during the initialisation process of the object.
* @method initializer
@ -4046,6 +4054,9 @@ EDITOR.prototype = {
if (this.get('readonly')) {
return;
}
// Check if passive option is supported for event listener
this.check_passive_supported();
// Setup the tool buttons.
Y.each(TOOLSELECTOR, function(selector, tool) {
toolnode = this.get_dialogue_element(selector);
@ -4139,6 +4150,16 @@ EDITOR.prototype = {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool;
}
var useragent = navigator.userAgent;
if (useragent.includes("Safari")) {
if (tool === "drag") {
this.enable_touch_scroll();
} else {
this.disable_touch_scroll();
}
}
this.refresh_button_state();
},
@ -4683,6 +4704,56 @@ EDITOR.prototype = {
for (i = 0; i < this.drawables.length; i++) {
this.drawables[i].scroll_update(x, y);
}
},
/**
* Check if Passive option is support
*/
check_passive_supported : function() {
try {
var options = Object.defineProperty && Object.defineProperty({}, 'passive', {
get: function() {
this.isPassiveSupported = true;
}.bind(this)
});
document.addEventListener('touchmove', options, options);
document.removeEventListener('touchmove', options, options);
} catch (err) {
this.isPassiveSupported = false;
}
},
/**
* Disable Touch Move scrolling
*/
disable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'hidden');
if (this.isPassiveSupported) {
document.addEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Enable Touch Move scrolling
*/
enable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'auto');
if (this.isPassiveSupported) {
document.removeEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Stop Touch Scrolling
* @param {Object} e
*/
stop_touch_scroll : function(e) {
e.stopPropagation();
e.preventDefault();
}
};
@ -4751,7 +4822,6 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
return M.assignfeedback_editpdf.instance;
};
}, '@VERSION@', {
"requires": [
"base",

View File

@ -3500,6 +3500,14 @@ EDITOR.prototype = {
*/
collapsecomments: true,
/**
* Check if passive option is supported
* @property isPassiveSupported
* @type Boolean
* @public
*/
isPassiveSupported : false,
/**
* Called during the initialisation process of the object.
* @method initializer
@ -4046,6 +4054,9 @@ EDITOR.prototype = {
if (this.get('readonly')) {
return;
}
// Check if passive option is supported for event listener
this.check_passive_supported();
// Setup the tool buttons.
Y.each(TOOLSELECTOR, function(selector, tool) {
toolnode = this.get_dialogue_element(selector);
@ -4139,6 +4150,16 @@ EDITOR.prototype = {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool;
}
var useragent = navigator.userAgent;
if (useragent.includes("Safari")) {
if (tool === "drag") {
this.enable_touch_scroll();
} else {
this.disable_touch_scroll();
}
}
this.refresh_button_state();
},
@ -4683,6 +4704,56 @@ EDITOR.prototype = {
for (i = 0; i < this.drawables.length; i++) {
this.drawables[i].scroll_update(x, y);
}
},
/**
* Check if Passive option is support
*/
check_passive_supported : function() {
try {
var options = Object.defineProperty && Object.defineProperty({}, 'passive', {
get: function() {
this.isPassiveSupported = true;
}.bind(this)
});
document.addEventListener('touchmove', options, options);
document.removeEventListener('touchmove', options, options);
} catch (err) {
this.isPassiveSupported = false;
}
},
/**
* Disable Touch Move scrolling
*/
disable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'hidden');
if (this.isPassiveSupported) {
document.addEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Enable Touch Move scrolling
*/
enable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'auto');
if (this.isPassiveSupported) {
document.removeEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Stop Touch Scrolling
* @param {Object} e
*/
stop_touch_scroll : function(e) {
e.stopPropagation();
e.preventDefault();
}
};
@ -4751,7 +4822,6 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
return M.assignfeedback_editpdf.instance;
};
}, '@VERSION@', {
"requires": [
"base",

View File

@ -227,6 +227,14 @@ EDITOR.prototype = {
*/
collapsecomments: true,
/**
* Check if passive option is supported
* @property isPassiveSupported
* @type Boolean
* @public
*/
isPassiveSupported : false,
/**
* Called during the initialisation process of the object.
* @method initializer
@ -773,6 +781,9 @@ EDITOR.prototype = {
if (this.get('readonly')) {
return;
}
// Check if passive option is supported for event listener
this.check_passive_supported();
// Setup the tool buttons.
Y.each(TOOLSELECTOR, function(selector, tool) {
toolnode = this.get_dialogue_element(selector);
@ -866,6 +877,16 @@ EDITOR.prototype = {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool;
}
var useragent = navigator.userAgent;
if (useragent.includes("Safari")) {
if (tool === "drag") {
this.enable_touch_scroll();
} else {
this.disable_touch_scroll();
}
}
this.refresh_button_state();
},
@ -1410,6 +1431,56 @@ EDITOR.prototype = {
for (i = 0; i < this.drawables.length; i++) {
this.drawables[i].scroll_update(x, y);
}
},
/**
* Check if Passive option is support
*/
check_passive_supported : function() {
try {
var options = Object.defineProperty && Object.defineProperty({}, 'passive', {
get: function() {
this.isPassiveSupported = true;
}.bind(this)
});
document.addEventListener('touchmove', options, options);
document.removeEventListener('touchmove', options, options);
} catch (err) {
this.isPassiveSupported = false;
}
},
/**
* Disable Touch Move scrolling
*/
disable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'hidden');
if (this.isPassiveSupported) {
document.addEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Enable Touch Move scrolling
*/
enable_touch_scroll : function() {
var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setStyle('overflow', 'auto');
if (this.isPassiveSupported) {
document.removeEventListener('touchmove', this.stop_touch_scroll, {passive: false});
}
},
/**
* Stop Touch Scrolling
* @param {Object} e
*/
stop_touch_scroll : function(e) {
e.stopPropagation();
e.preventDefault();
}
};
@ -1476,4 +1547,4 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
M.assignfeedback_editpdf.instance = new EDITOR(params);
return M.assignfeedback_editpdf.instance;
};
};