mapbox-gl-circle icon indicating copy to clipboard operation
mapbox-gl-circle copied to clipboard

Emit a 'radiuschanging' event

Open eddydg opened this issue 6 years ago • 3 comments

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 avatar May 07 '18 10:05 eddydg

@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).

ghost avatar May 27 '18 16:05 ghost

Please put up a pull request if you have a good strategy for adding this feature!

mblomdahl avatar May 27 '18 16:05 mblomdahl

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.

eddydg avatar May 28 '18 13:05 eddydg