You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/10/29 20:28:07 UTC

[incubator-echarts] branch fix/brush-globalout created (now 87196f3)

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a change to branch fix/brush-globalout
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


      at 87196f3  enhance: enhance the behavior that when mouse move is out of echarts area: the brushed area or dataZoom window will be released at that case, but not keep in dragging state. fix #10675.

This branch includes the following new commits:

     new 87196f3  enhance: enhance the behavior that when mouse move is out of echarts area: the brushed area or dataZoom window will be released at that case, but not keep in dragging state. fix #10675.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[incubator-echarts] 01/01: enhance: enhance the behavior that when mouse move is out of echarts area: the brushed area or dataZoom window will be released at that case, but not keep in dragging state. fix #10675.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch fix/brush-globalout
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 87196f3a65183373c8f40139d4e6c8042476bebe
Author: SHUANG SU <su...@gmail.com>
AuthorDate: Wed Oct 30 04:27:21 2019 +0800

    enhance: enhance the behavior that when mouse move is out of echarts area: the brushed area or dataZoom window will be released at that case, but not keep in dragging state. fix #10675.
---
 src/component/helper/BrushController.js | 59 ++++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 15 deletions(-)

diff --git a/src/component/helper/BrushController.js b/src/component/helper/BrushController.js
index c1106fb..caa753d 100644
--- a/src/component/helper/BrushController.js
+++ b/src/component/helper/BrushController.js
@@ -138,6 +138,12 @@ function BrushController(zr) {
 
     /**
      * @private
+     * @type {Object}
+     */
+    this._lastMouseMovePoint = {};
+
+    /**
+     * @private
      * @type {Array}
      */
     this._covers = [];
@@ -820,7 +826,7 @@ var mouseHandlers = {
         if (this._dragging) {
             // In case some browser do not support globalOut,
             // and release mose out side the browser.
-            handleDragEnd.call(this, e);
+            handleDragEnd(this, e);
         }
         else if (!e.target || !e.target.draggable) {
 
@@ -839,7 +845,11 @@ var mouseHandlers = {
     },
 
     mousemove: function (e) {
-        var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
+        var lastPoint = this._lastMouseMovePoint;
+        lastPoint.x = e.offsetX;
+        lastPoint.y = e.offsetY;
+
+        var localCursorPoint = this.group.transformCoordToLocal(lastPoint.x, lastPoint.y);
 
         resetCursor(this, e, localCursorPoint);
 
@@ -853,27 +863,46 @@ var mouseHandlers = {
         }
     },
 
-    mouseup: handleDragEnd //,
+    mouseup: function (e) {
+        handleDragEnd(this, e);
+    },
 
-    // FIXME
-    // in tooltip, globalout should not be triggered.
-    // globalout: handleDragEnd
+    globalout: function (e) {
+        handleDragEnd(this, e, true);
+    }
 };
 
-function handleDragEnd(e) {
-    if (this._dragging) {
+function handleDragEnd(controller, e, isGlobalOut) {
+    if (controller._dragging) {
 
-        preventDefault(e);
+        // Just be worried about bring some side effect to the world
+        // out of echarts, we do not `preventDefault` for globalout.
+        !isGlobalOut && preventDefault(e);
+
+        var pointerX = e.offsetX;
+        var pointerY = e.offsetY;
+        var lastPoint = controller._lastMouseMovePoint;
+        if (isGlobalOut) {
+            pointerX = lastPoint.x;
+            pointerY = lastPoint.y;
+        }
 
-        var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
-        var eventParams = updateCoverByMouse(this, e, localCursorPoint, true);
+        var localCursorPoint = controller.group.transformCoordToLocal(pointerX, pointerY);
+        // FIXME
+        // Here `e` is used only in `onIrrelevantElement` finally. And it's OK
+        // that pass the `e` of `globalout` to `onIrrelevantElement`. But it is
+        // not a good design of these interfaces. However, we do not refactor
+        // these code now because the implementation of `onIrrelevantElement`
+        // need to be discussed and probably be changed in future, becuase it
+        // slows down the performance of zrender in some cases.
+        var eventParams = updateCoverByMouse(controller, e, localCursorPoint, true);
 
-        this._dragging = false;
-        this._track = [];
-        this._creatingCover = null;
+        controller._dragging = false;
+        controller._track = [];
+        controller._creatingCover = null;
 
         // trigger event shoule be at final, after procedure will be nested.
-        eventParams && trigger(this, eventParams);
+        eventParams && trigger(controller, eventParams);
     }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org