Skip to content

Commit

Permalink
chore(transition): tweak wp page transition animation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Mar 4, 2016
1 parent a0235a5 commit 62c880f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ionic/components/alert/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class AlertWpPopIn extends Transition {
backdrop.fromTo('opacity', '0.01', '0.5');

this
.easing('cubic-bezier(0, 0, 0.05, 1)')
.easing('cubic-bezier(0,0 0.05,1)')
.duration(200)
.add(backdrop)
.add(wrapper);
Expand Down
2 changes: 1 addition & 1 deletion ionic/config/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Config.setModeConfig('wp', {
modalEnter: 'modal-md-slide-in',
modalLeave: 'modal-md-slide-out',

pageTransition: 'md-transition',
pageTransition: 'wp-transition',
pageTransitionDelay: 96,

tabbarPlacement: 'top',
Expand Down
1 change: 1 addition & 0 deletions ionic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ import './platform/registry'
import './animations/builtins'
import './transitions/transition-ios'
import './transitions/transition-md'
import './transitions/transition-wp'
63 changes: 63 additions & 0 deletions ionic/transitions/transition-wp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {Animation} from '../animations/animation';
import {Transition, TransitionOptions} from './transition';
import {ViewController} from '../components/nav/view-controller';

const SHOW_BACK_BTN_CSS = 'show-back-button';
const SCALE_SMALL = .95;


class WPTransition extends Transition {

constructor(enteringView: ViewController, leavingView: ViewController, opts: TransitionOptions) {
super(opts);

// what direction is the transition going
let backDirection = (opts.direction === 'back');

// do they have navbars?
let enteringHasNavbar = enteringView.hasNavbar();
let leavingHasNavbar = leavingView && leavingView.hasNavbar();

// entering content scale from smaller to larger
let enteringPage = new Animation(enteringView.pageRef());
enteringPage.before.addClass('show-page');
this.add(enteringPage);

if (backDirection) {
this.duration(opts.duration || 120).easing('cubic-bezier(0.47,0,0.745,0.715)');
enteringPage.before.clearStyles(['scale']);

} else {
this.duration(opts.duration || 280).easing('cubic-bezier(0,0 0.05,1)');
enteringPage
.fromTo('scale', SCALE_SMALL, 1, true)
.fadeIn();
}

if (enteringHasNavbar) {
let enteringNavBar = new Animation(enteringView.navbarRef());
enteringNavBar.before.addClass('show-navbar');
this.add(enteringNavBar);

let enteringBackButton = new Animation(enteringView.backBtnRef());
this.add(enteringBackButton);
if (enteringView.enableBack()) {
enteringBackButton.before.addClass(SHOW_BACK_BTN_CSS);
} else {
enteringBackButton.before.removeClass(SHOW_BACK_BTN_CSS);
}
}

// setup leaving view
if (leavingView && backDirection) {
// leaving content
this.duration(opts.duration || 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
let leavingPage = new Animation(leavingView.pageRef());
this.add(leavingPage.fromTo('scale', 1, SCALE_SMALL).fadeOut());
}

}

}

Transition.register('wp-transition', WPTransition);

0 comments on commit 62c880f

Please sign in to comment.