Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetzoom triggering after drag (beta) #441

Closed
pgp80 opened this issue Mar 15, 2021 · 4 comments · Fixed by #455 or #484
Closed

resetzoom triggering after drag (beta) #441

pgp80 opened this issue Mar 15, 2021 · 4 comments · Fixed by #455 or #484
Labels
Milestone

Comments

@pgp80
Copy link

pgp80 commented Mar 15, 2021

I'm trying out the betas of both chartjs and zoom, and I'm noticing some behavior which is different from the current versions I have on a project. I have drag zoom enabled and in the current version, it zooms and then I have onClick: resetZoom and it reverts to original form. In the beta, I drag and as soon as I release the mouse the resetZoom occurs immediately (so it doesn't stay zoomed in). Removing the onClick in the beta does result in a stable zooming. Just thought I'd share!
``
options: {

scales: {
  x: {
  	type: 'time',
      unit: 'hour'
  },//end x
  y: {
    
  }//end y
},//end scales
 
plugins: {
  zoom: {
    
    zoom: {
      enabled: true,
      drag: true,
      mode: 'x',
    
    }
  }
},
onClick: resetZoom,

}//end options

recording (1)

@kurkle
Copy link
Member

kurkle commented Mar 15, 2021

Thanks for the heads up, I'm guessing it should not call "onClick" when dragging.

@kurkle kurkle added the bug label Mar 15, 2021
@kurkle kurkle added this to the 1.0.0 milestone Mar 15, 2021
@jledentu
Copy link
Collaborator

@kurkle I think it's the native behavior to have mouseup and click events triggered simultaneously, even if mousemove events were triggered between the mousedown and mouseup. I don't know why it worked in previous versions, but I think that a onClick callback is expected when a click event natively happens, don't you think?

@pgp80 There are some tricks to distinguish quick click and "drag" events: https://stackoverflow.com/questions/6042202/how-to-distinguish-mouse-click-and-drag.

@pgp80
Copy link
Author

pgp80 commented Apr 30, 2021

I've been trying the latest betas and the drag still appears to be triggering the onClick: resetZoom on my end. I suppose I can try the tricks per the above, but just figured I'd let you know in case this still isn't intended behavior, thanks!

@kurkle
Copy link
Member

kurkle commented Apr 30, 2021

@pgp80 is your click handler on the chart options or in the canvas element?

NVM, just verified it is only filtered out when panning, but not when drag zooming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants