NightRa commented on code in PR #21655:
URL: https://github.com/apache/echarts/pull/21655#discussion_r3681854836


##########
src/component/helper/RoamController.ts:
##########
@@ -195,16 +205,20 @@ class RoamController extends 
Eventful<RoamEventDefinition> {
                 this.disable();
 
                 this._enabled = true;
-                if (controlType === true || (controlType === 'move' || 
controlType === 'pan')) {
+                if (moveEnabled) {
                     addRoamZrListener(zr, 'mousedown', mousedownHandler, 
zInfoParsed);
                     addRoamZrListener(zr, 'mousemove', mousemoveHandler, 
zInfoParsed);
                     addRoamZrListener(zr, 'mouseup', mouseupHandler, 
zInfoParsed);
                 }
-                if (controlType === true || (controlType === 'scale' || 
controlType === 'zoom')) {
+                if (zoomEnabled) {
                     addRoamZrListener(zr, 'mousewheel', mousewheelHandler, 
zInfoParsed);
+                }
+                if (moveEnabled || zoomEnabled) {
                     addRoamZrListener(zr, 'pinch', pinchHandler, zInfoParsed);
                 }
             }
+            this._moveEnabled = moveEnabled;
+            this._zoomEnabled = zoomEnabled;

Review Comment:
   Thanks, you’re correct that _controlType is never assigned, so the existing 
idempotency check always removes and re-adds the listeners. This behavior 
predates this PR.
   
   Assigning _controlType alone may not be safe, however. Listener registration 
also captures component, zlevel, z, and z2, which determine precedence between 
overlapping controllers. These values are recalculated by every enable() call; 
skipping registration solely because controlType is unchanged could leave stale 
ordering metadata when a component’s z-order changes.
   
   A complete fix should invalidate or update the registration when either 
controlType or that z-order metadata changes. Since this is an existing issue 
rather than a regression from the pinch changes, I suggest handling it 
separately.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to