Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
255 stars 85 forks source link

Disable chart panning and zooming (d3-zoom) #98

Closed MartinvonBerg closed 3 years ago

MartinvonBerg commented 3 years ago

Hi, again I have a question concerning the code: There is a function to do a rescale / zoom for the horizontal x-axis of the elevation chart with CTRL + scroll-wheel. Is there an option to disable that? I checked options.js but couldn't see an option that seems to allow that. Thank's again! Best Regards Martin

Raruto commented 3 years ago

Hi Martin, take a look at version 1.6.7

https://github.com/Raruto/leaflet-elevation/blob/97bdf8a66420f66d19097ee301a66a1226cd555b/src/options.js#L100

in this version I also changed the "zooming" behavior as follows:

zoom = shift + wheel pan = shift + drag or wheel click + drag

Have a nice day, Raruto

MartinvonBerg commented 3 years ago

Hi,

Thank's for the hint. I tested V 1.6.7. on Sunday, but it did not work with my code. In consequence that means that my code is not compatible to the "API" you provide with leaflet-elevation. I haven't time to change that now.

For the moment I commented out in the method _appendClipper the lines after the "var" section, except the return g, roughly lines 1115 -1150 https://github.com/Raruto/leaflet-elevation/blob/ca365fe2c52c9bf21239de3d405e920461b740bd/src/chart.js#L374-L432 and that stops the scaling.

So, you may close the issue.

Best Regards and Thank you very much for the support.

Martin

Raruto commented 3 years ago

Ok thanks for report,

if it can help you version 1.6.7 has completely altered the internal rendering logic (mainly to optimize graph resizing, before this, everything was always redrawn with obvious performance issues)

Here https://github.com/Raruto/leaflet-elevation/commit/7c0262cf1f6fce0a46cbbf345c5a09745b282903 you can find all the changes that have been made.

Have a nice day, Raruto