angular-snap.js icon indicating copy to clipboard operation
angular-snap.js copied to clipboard

open/close events on drag

Open jdhiro opened this issue 13 years ago • 6 comments

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.

jdhiro avatar Dec 02 '13 22:12 jdhiro

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()

jdhiro avatar Dec 02 '13 23:12 jdhiro

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.

jtrussell avatar Dec 03 '13 02:12 jtrussell

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 =)

jdhiro avatar Dec 03 '13 19:12 jdhiro

I can't seem to get a watch statement on snapper.state().state to work. Would you be able to provide an example?

FreakTheMighty avatar Mar 04 '14 08:03 FreakTheMighty

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.

jtrussell avatar Mar 04 '14 13:03 jtrussell

~~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;
        }
    });
});

irizvi avatar Jul 13 '15 15:07 irizvi