MDL-62319 Assign: Grading interface is broken when using iOS 11.3 devices
authorNathan Nguyen <nathannguyen@catalyst-au.net>
Mon, 20 Aug 2018 02:56:34 +0000 (12:56 +1000)
committerDamyon Wiese <damyon@moodle.com>
Thu, 11 Oct 2018 05:27:56 +0000 (13:27 +0800)
mod/assign/feedback/editpdf/styles.css
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js
mod/assign/feedback/editpdf/yui/src/editor/js/editor.js

index 1630264..5c10516 100644 (file)
@@ -35,6 +35,7 @@
     position: absolute;
     overflow: auto;
     background-color: #ccc;
+    touch-action: none;
 }
 
 .assignfeedback_editpdf_widget {
index dc22ae1..98135eb 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js differ
index 827e3d2..3c52a7e 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js differ
index dc22ae1..98135eb 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js differ
index 4320b85..f4246cd 100644 (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;
-};
+};
\ No newline at end of file