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

Label rotation randomly not working #258

Closed hupe13 closed 1 year ago

hupe13 commented 1 year ago

https://github.com/Raruto/leaflet-elevation/pull/252#issuecomment-1528819214

Some things do not seem to work properly.

I think I have found the reason. I tested the same page with one elevation chart in Firefox and Chrome. The label rotation was random (yes or no), even in different tabs of the same browser. I changed the line https://github.com/Raruto/leaflet-elevation/blob/e0c68cba9a71d140e4c5a4179c51ae34588b7327/src/handlers/labels.js#L11 to

this.on('elechart_init elechart_axis elechart_updated', function(e) {

and the effect did not occur anymore. Not even with multiple charts with different rotations on the same page.

Raruto commented 1 year ago

The initial idea was to try to limit the number DOM mutations (perhaps feasible, but it would still require other thoughts..).

Anyway, something like this could suffice (I haven't tested):

this.on('elechart_updated', function(e) {

Feel free to submit a pull request to close it.

👋 Raruto