Skip to content

Commit

Permalink
Add zoom threshold (chartjs#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
BolyavinMA committed May 5, 2020
1 parent f3e13d6 commit 6a7c970
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ plugins: {
// (percentage of zoom on a wheel event)
speed: 0.1,

// Minimal zoom distance required before actually applying zoom
threshold: 2,

// On category scale, minimal zoom level before actually applying zoom
sensitivity: 3,

Expand Down
3 changes: 2 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ var zoomPlugin = {
chartInstance.$zoom._dragZoomStart = null;
chartInstance.$zoom._dragZoomEnd = null;

if (dragDistanceX <= 0 && dragDistanceY <= 0) {
var zoomThreshold = options.zoom && options.zoom.threshold || 0;
if (dragDistanceX <= zoomThreshold && dragDistanceY <= zoomThreshold) {
return;
}

Expand Down

0 comments on commit 6a7c970

Please sign in to comment.