Closed Thuranel closed 7 years ago
@Thuranel Great, looks good.
Did you try to add a test for this?
Here you go!
There is probably one test missing to make sure that the 'move' event is called on every single tick of dragging, but I've been looking at it all morning and it doesn't seem possible to simulate multiple ticks with phantomjs because everything happens all at once. My understanding is that since there is no delay between the drag and the drop the _updatePosition function is only called once. Also, if you try to make a timeout between the drag and the drop or before asserting, it seems that the test framework doesn't wait for everything to finish before arriving at the end of the test and claiming the test passed (because the assert has not been run yet). If there was a way to wait for one frame we could probably make a test to see if the event is fired more than once.
Until then, that's the best I got. The basic behavior is tested and should be good.
great, thanks for the effort. Every test is better than nothing!
released leaflet.sync@0.0.7
This pull request is for issue #34.
This PR changes the following: When dragging the map, the 'move' event is called instead of 'moveend'. On dragend, the 'moveend' event is called on the synced maps.
These changes make it so the appropriate event is called. Before these changes 'moveend' was called on every single move. Therefore, not when the move ended like the event says. Here's a fiddle showing the issue: https://jsfiddle.net/Thuranel/zmp3qfqe/
Now, the 'moveend' event is only called at the end of dragging and the 'move' event is called while dragging the map. This keep the usual behavior while firing the appropriate events. Here's a fiddle showing the behavior with this PR: https://jsfiddle.net/Thuranel/gmjcom01/