open/close events on drag
It would be really nice if the open/close events were supported on drag.
For example, I use these events to set a CSS class on my navigation header. The class is properly set when I touch the menu button, but it is not set when I drag the window and it 'snaps' open or closed.
I just realized that this is an issue with snap.js, and not angular-snap. I was able to create this easily by using the snapper.on('animated') event and checking snapper.state()
Nice - just a heads up I think version 2.x of Snap.js is looking to drop at least the animating event... not sure if the animated event is sticking around or not. You might be able to accomplish a similar thing by $watching snapper.state().state? Just a thought.
Hm, good call, that is probably the more 'Angular' way of doing it. Animated is working for now though, so I'll just wait and see =)
I can't seem to get a watch statement on snapper.state().state to work. Would you be able to provide an example?
After playing around with this a bit it's definitely tougher than I initially imagined :p mostly because there doesn't seem to a convenient or reliable place to trigger a digest... at least not that I can see.
Here are some musings that might get you going, it works-ish though I'm not recommending you use it in production... just hopefully sparking some inspiration. FWIW I think I'd likely just stick with snapper.on('animated') as @jdhiro suggests.
~~Was there any progress made on this? I'm having a similar issue where I need to "watch" for when the drawer is toggled and animated.~~
Nevermind, got it working with this:
snapRemote.getSnapper().then(function(snapper) {
snapper.on('animated', function() {
if(snapper.state().state === 'closed'){
$scope.isActive = false;
} else if (snapper.state().state === 'left'){
$scope.isActive = true;
}
});
});