TutteInstitute / datamapplot

Creating beautiful plots of data maps
MIT License
786 stars 50 forks source link

Question about smooth zoom #35

Open zilch42 opened 2 months ago

zilch42 commented 2 months ago

Hi there, so I've noticed that the animations of the interactive plots on the documentation site show smooth transitions between zoom levels, which looks great, however when I use the live example plots on the documentation website, as well as with interactive plots I have generated myself in jupyter notebook, the zoom is stepped rather than smooth. Is there anything specific I can do to get the smooth zoom transitions back?

https://github.com/user-attachments/assets/cad7f2dc-436f-4554-9b33-c6ab0570c2e5

lmcinnes commented 2 months ago

I can't say for sure, as I don't know your system, but one possibility is that you are zooming by using the scrollwheel on a mouse. This results in a scroll working in increments which results in stepped zooming. I have a mouse that has a free scrolling wheel which is smoother (than when I have it in stepped scrolling mode). The videos were created on a laptop with a trackpad that allows for smooth scrolling -- any touch based device (potentially using pinch-to-zoom) should also work.

lmcinnes commented 2 months ago

After some digging it turns out that deck.gl actually supports a smooth zoom option even for mousewheels. You can test this by editing the generated HTML and adding:

controller: { scrollZoom: {speed: 0.01, smooth: true } },

in place of the line:

controller: true,

I'll do some testing to ensure this will all work in general and then hopefully amend the code to support this generally.

zilch42 commented 2 months ago

Thanks! controller: { scrollZoom: {speed: 0.01, smooth: true } }, worked for me!