MDL-52825 atto: Listen to gesturemovestart to discard some events
authorDavid Monllao <davidm@moodle.com>
Thu, 28 Jan 2016 03:31:33 +0000 (11:31 +0800)
committerDavid Monllao <davidm@moodle.com>
Fri, 29 Jan 2016 02:15:26 +0000 (10:15 +0800)
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js
lib/editor/atto/yui/src/editor/js/selection.js

index 1fe8ee2..09ab53f 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js and b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js differ
index 75083cd..b6ff702 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js and b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js differ
index f158f16..bbc68c7 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js and b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js differ
index ad5e77f..e90b30a 100644 (file)
@@ -64,6 +64,16 @@ EditorSelection.prototype = {
      */
     _focusFromClick: false,
 
+    /**
+     * Whether if the last gesturemovestart event target was contained in this editor or not.
+     *
+     * @property _gesturestartededitor
+     * @type Boolean
+     * @default false
+     * @private
+     */
+    _gesturestartededitor: false,
+
     /**
      * Set up the watchers for selection save and restoration.
      *
@@ -94,18 +104,21 @@ EditorSelection.prototype = {
                 Y.soon(Y.bind(this._hasSelectionChanged, this, e));
             }, this);
 
-        // To capture both mouseup and touchend events, we need to track the gesturemoveend event in standAlone mode. Without
-        // standAlone, it will only fire if we listened to a gesturemovestart too.
-        this.editor.on('gesturemoveend', function(e) {
+        Y.one(document.body).on('gesturemovestart', function(e) {
+            if (this._wrapper.contains(e.target._node)) {
+                this._gesturestartededitor = true;
+            } else {
+                this._gesturestartededitor = false;
+            }
+        }, null, this);
 
-            // Ignore the event if the target is not part of the current editor.
-            if (!this._wrapper.contains(e.target._node)) {
+        Y.one(document.body).on('gesturemoveend', function(e) {
+            if (!this._gesturestartededitor) {
+                // Ignore the event if movestart target was not contained in the editor.
                 return;
             }
             Y.soon(Y.bind(this._hasSelectionChanged, this, e));
-        }, {
-            standAlone: true
-        }, this);
+        }, null, this);
 
         return this;
     },