mapbox-gl-circle
mapbox-gl-circle copied to clipboard
Emit a 'radiuschanging' event
For a more advanced styling I'd need to keep track of a circle whose radius is being dragged. Currently we only have 'radiuschanged' which is emitted once the drag has ended. So a 'radiuschanging' could come in handy.
To be consistent, a 'centerchanging' could also be added.
What do you think? would you accept a PR with this feature?
@eddydg Do you mean it should fire repeatedly every time we get a rAF slot during animation? Sounds like it would degrade performance (one of our biggest challenges).
Please put up a pull request if you have a good strategy for adding this feature!
Thank you for your answers. I'm not sure what a rAF slot
is.
I was thinking about something very (too?) simple: adding
this._eventEmitter.emit('radiuschanging', this);
in the set radius
and
this._eventEmitter.emit('centerchanging', this);
in the set center
.
PR: https://github.com/smithmicro/mapbox-gl-circle/pull/77
I am not seeing any visible difference in performance but I am keeping a very light playground: http://lab.meltedpeng.com/mapbox-gl-circle/
Edit: Oh ok, rAF for requestAnimationFrame. Never used this abbreviation.
It fires when the center changes, so reacting to the _onRadiusHandlesMouseDown
and _onRadiusHandlesMouseMove
listeners.