bluehalo / ngx-leaflet-draw

MIT License
88 stars 29 forks source link

draw:created event behaviour difference #76

Closed patolax closed 5 years ago

patolax commented 5 years ago

When I try to show a component or matdialog window with progressbar change detection is not working properly during leafletMap.on('draw:created') event mainly. Things start to change if I fire a change detection cycle programmatically. But the behavior of the new component is very unpredictable.

This problem does not occur in draw:deleted and draw:edited callbacks. Any reason for this to happen in draw:created callback and how can we avoid it?

leafletMap.on('draw:created', function (e: L.DrawEvents.Created) { showprogressdialog(); }

reblace commented 5 years ago

Since you are registering the callback directly on leaflet, it's outside of the Angular zone. As a result, there's no guarantee that Angular change detection is going to work.

There are a couple of ways to address this described in the @asymmetrik/ngx-leaflet README: https://github.com/Asymmetrik/ngx-leaflet#a-note-about-change-detection

patolax commented 5 years ago

Thanks, it worked.