100pah commented on a change in pull request #11037: new: 10491-support mouse
wheel in slider data zoom
URL:
https://github.com/apache/incubator-echarts/pull/11037#discussion_r322721891
##########
File path: src/component/dataZoom/SliderZoomView.js
##########
@@ -776,6 +779,52 @@ var SliderZoomView = DataZoomView.extend({
});
},
+ /**
+ * Zoom with the mouse wheel
+ * We simply simulate handle zoom
+ * @private
+ */
+ _mouseWheelZoom: function (e) {
+ const STEP_SIZE = 10;
+
+ // stop wheel navigation so page won't scroll
+ eventTool.stop(e.event);
+
+ // Transform dx, dy to bar coordination.
+ var barTransform = this._displayables.barGroup.getLocalTransform();
+
+ // don't zoom in too much, so sliders won't switch places
+ // and then mouse wheel will invert
+ if (this._range[1] - this._range[0] <= STEP_SIZE) {
+ if (e.wheelDelta > 0) {
+ return;
+ }
+ }
+
+ for (const handleIndex of [0, 1]) {
+ // calculate zoom transform size according to current slider
+ var handleStepSize = STEP_SIZE * (e.wheelDelta > 0 ? -1 : 1);
+ if (handleIndex == 1) {
+ handleStepSize = handleStepSize * -1;
+ }
+ if (this._orient == "horizontal") {
+ handleStepSize = handleStepSize * -1;
+ }
Review comment:
(1) We should better use `===` but not `==`.
(2) We should use single quotation but not double quotation in JS literal
string. (`'horizontal'`).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]