Skip to content

Commit

Permalink
Fix broken zoom functionality (danvk#611) in the drawing test
Browse files Browse the repository at this point in the history
Same as PR#953 fixed for the gallery, really.
  • Loading branch information
mirabilos committed Feb 16, 2023
1 parent 96a63a5 commit e24d675
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/drawing.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ <h2>Time Series Drawing Demo</h2>
labels: [ 'Date', 'Value' ],
labelsUTC: true,
interactionModel: {
// the next line is required when using the
// defaultInteractionModel mousedown function.
willDestroyContextMyself: true,
mousedown: function (event, g, context) {
if (tool == 'zoom') {
Dygraph.defaultInteractionModel.mousedown(event, g, context);
Expand All @@ -153,21 +156,25 @@ <h2>Time Series Drawing Demo</h2>
}
},
mousemove: function (event, g, context) {
if (tool == 'zoom') {
} else {
// note that the defaultInteractionModel dynamically binds
// its own mousemove event inside the mousedown handler
if (tool != 'zoom') {
if (!isDrawing) return;
setPoint(event, g, context);
}
},
mouseup: function(event, g, context) {
if (tool == 'zoom') {
} else {
// note that the defaultInteractionModel dynamically binds
// its own mouseup event inside the mousedown handler
if (tool != 'zoom') {
finishDraw();
}
},
mouseout: function(event, g, context) {
if (tool == 'zoom') {
}
// note that the defaultInteractionModel does not use
// the mouseout event, instead it detects when the mouse
// is outside the chart using a dynamically bound
// mousemove event
},
dblclick: function(event, g, context) {
Dygraph.defaultInteractionModel.dblclick(event, g, context);
Expand Down

0 comments on commit e24d675

Please sign in to comment.