Skip to content

Commit e6555d4

Browse files
glemironBolyavinMA
andauthored
Add zoom threshold (#317) (#347)
Co-authored-by: BolyavinMA <[email protected]>
1 parent f3e13d6 commit e6555d4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ plugins: {
103103
// (percentage of zoom on a wheel event)
104104
speed: 0.1,
105105

106+
// Minimal zoom distance required before actually applying zoom
107+
threshold: 2,
108+
106109
// On category scale, minimal zoom level before actually applying zoom
107110
sensitivity: 3,
108111

src/plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ var zoomPlugin = {
482482
chartInstance.$zoom._dragZoomStart = null;
483483
chartInstance.$zoom._dragZoomEnd = null;
484484

485-
if (dragDistanceX <= 0 && dragDistanceY <= 0) {
485+
var zoomThreshold = options.zoom && options.zoom.threshold || 0;
486+
if (dragDistanceX <= zoomThreshold && dragDistanceY <= zoomThreshold) {
486487
return;
487488
}
488489

0 commit comments

Comments
 (0)