Skip to content

Instantly share code, notes, and snippets.

@mlynch
Last active August 29, 2015 14:01
Show Gist options
  • Save mlynch/2336e45065f0b2e9a994 to your computer and use it in GitHub Desktop.
Save mlynch/2336e45065f0b2e9a994 to your computer and use it in GitHub Desktop.
first idea for nav transition stuff
/**
* For each navigation controller on scope, we can have one child control animation during transitions
* by enabling overriding a function:
*/
controller('MyCtrl', function($scope, $ionicNavDelegate, $ionicAnimation)) {
var pushAnim = $ionicAnimation({
duration: 1,
curve: 'ease-in-out',
step: function(v) {
this.context.fromEl.style[ionic.CSS.Transform] = 'translate3d(' + -v + 'px, 0,0)';
this.context.toEl.style[ionic.CSS.Transform] = 'translate3d(' + v + 'px, 0,0)';
}
})
var nav = $ionicNavDelegate($scope);
nav.getAnimator = function(transition) {
/**
* getAnimator is a function that gets passed an obj like:
* {
* direction: 'push', 'pop',
* from: angular.element?
* to: angular.element?
* }
* This lets us have different animations for push and pop, and matches
* the new overridable transition stuff in iOS 7:
* https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UINavigationControllerDelegate/navigationController:animationControllerForOperation:fromViewController:toViewController:
*/
if(direction == 'push') {
return pushAnim;
}
if(direction == 'pop') {
return popAnim;
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment