shprink / ionic-native-transitions

[Maintenance only] Native transitions (iOS & Android) for Ionic Framework
https://www.npmjs.com/package/ionic-native-transitions
MIT License
572 stars 112 forks source link

Add support for calling stateGo() with no transitions #106

Closed neslinesli93 closed 8 years ago

neslinesli93 commented 8 years ago

Digging through the code, I found that $ionicNativeTransitions.stateGo()will resort to defaultOptions or eventually to slide if no transition object is passed to it. However, it would be very useful to have an option to make it perform no animation when requested. Thanks!

shprink commented 8 years ago

You can use events to enable/disable transitions when you need.

https://github.com/shprink/ionic-native-transitions#events

https://github.com/shprink/ionic-native-transitions#enabledisable-optional

neslinesli93 commented 8 years ago

So the correct way to do this is to listen to ionicNativeTransitions.beforeTransition, disable the plugin, and then enable it again after the transition happened?

shprink commented 8 years ago

before calling stateGo you can disable the plugin and re enable it right after.

kmturley commented 8 years ago

It'd be great if transitions could support state params e.g.

$rootScope.$broadcast('ionicNativeTransitions.beforeBackTransition', toStateTransition, currentStateTransition);

So you could then use:

$rootScope.$on('ionicNativeTransitions.beforeBackTransition', function (event, toState, fromState) {
    if (fromState.name === 'submit' && toState.name === 'edit') {
        event.preventDefault();
        console.log('do something');
    }
});

And some way to prevent default on the event to cancel the transition!

ghost commented 8 years ago

@kmturley Brilliant idea. But untill it is implemented we can use $stateChangeStart and $stateChangeSuccess to achieve this functionality if you're using ui-router.