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

This commit is contained in:
Nathan Nguyen
2018-10-11 13:33:11 +08:00
committed by Damyon Wiese
parent 57241c56c0
commit edbc4b5816
5 changed files with 219 additions and 7 deletions
+1
View File
@@ -44,6 +44,7 @@
position: absolute;
overflow: auto;
background-color: #ccc;
touch-action: none;
}
.assignfeedback_editpdf_widget {
@@ -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
@@ -4027,6 +4035,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);
@@ -4120,6 +4131,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();
},
@@ -4664,6 +4685,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();
}
};
@@ -4732,7 +4803,6 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
return M.assignfeedback_editpdf.instance;
};
}, '@VERSION@', {
"requires": [
"base",
File diff suppressed because one or more lines are too long
@@ -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
@@ -4027,6 +4035,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);
@@ -4120,6 +4131,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();
},
@@ -4664,6 +4685,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();
}
};
@@ -4732,7 +4803,6 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
return M.assignfeedback_editpdf.instance;
};
}, '@VERSION@', {
"requires": [
"base",
+72 -1
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
@@ -754,6 +762,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);
@@ -847,6 +858,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();
},
@@ -1391,6 +1412,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();
}
};
@@ -1457,4 +1528,4 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
M.assignfeedback_editpdf.instance = new EDITOR(params);
return M.assignfeedback_editpdf.instance;
};
};