mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
md transition
This commit is contained in:
@ -8,13 +8,9 @@ import {Platform} from '../../platform/platform';
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
home: {
|
'home': {
|
||||||
ios: 'ion-ios-home',
|
ios: ['ion-ios-home', 'ion-ios-home-outline'],
|
||||||
md: 'ion-md-home'
|
md: 'ion-md-home'
|
||||||
},
|
|
||||||
star: {
|
|
||||||
ios: 'ion-ios-star',
|
|
||||||
md: 'ion-md-star',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1-for-1 swap
|
1-for-1 swap
|
||||||
|
@ -81,6 +81,6 @@ export class FirstPage {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
push() {
|
push() {
|
||||||
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
|
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ export class ViewController extends Ion {
|
|||||||
injector: Injector,
|
injector: Injector,
|
||||||
elementRef: ElementRef
|
elementRef: ElementRef
|
||||||
) {
|
) {
|
||||||
super(elementRef, injector.get(IonicConfig));
|
let config = injector.get(IonicConfig);
|
||||||
|
super(elementRef, config);
|
||||||
|
|
||||||
this.parent = parentViewCtrl;
|
this.parent = parentViewCtrl;
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ export class ViewController extends Ion {
|
|||||||
this.viewMngr = injector.get(AppViewManager);
|
this.viewMngr = injector.get(AppViewManager);
|
||||||
this.router = injector.get(IonicRouter);
|
this.router = injector.get(IonicRouter);
|
||||||
this.app = injector.get(IonicApp);
|
this.app = injector.get(IonicApp);
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
this.router.addViewController(this);
|
this.router.addViewController(this);
|
||||||
|
|
||||||
@ -203,6 +205,9 @@ export class ViewController extends Ion {
|
|||||||
|
|
||||||
if (opts.animate === false) {
|
if (opts.animate === false) {
|
||||||
opts.animation = 'none';
|
opts.animation = 'none';
|
||||||
|
|
||||||
|
} else if (!opts.animation) {
|
||||||
|
opts.animation = this.config.setting('viewTransition');
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.animate = (opts.animation !== 'none');
|
opts.animate = (opts.animation !== 'none');
|
||||||
|
@ -22,3 +22,4 @@ export * from 'ionic/animations/builtins'
|
|||||||
|
|
||||||
export * from 'ionic/transitions/transition'
|
export * from 'ionic/transitions/transition'
|
||||||
export * from 'ionic/transitions/ios-transition'
|
export * from 'ionic/transitions/ios-transition'
|
||||||
|
export * from 'ionic/transitions/md-transition'
|
||||||
|
@ -5,7 +5,8 @@ Platform.register({
|
|||||||
name: 'core',
|
name: 'core',
|
||||||
settings: {
|
settings: {
|
||||||
mode: 'ios',
|
mode: 'ios',
|
||||||
iconMode: 'ios'
|
iconMode: 'ios',
|
||||||
|
viewTransition: 'ios'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Platform.setDefault('core');
|
Platform.setDefault('core');
|
||||||
@ -51,12 +52,12 @@ Platform.register({
|
|||||||
mode: 'md',
|
mode: 'md',
|
||||||
iconMode: 'md',
|
iconMode: 'md',
|
||||||
type: 'overlay',
|
type: 'overlay',
|
||||||
keyboardScrollAssist: true
|
keyboardScrollAssist: true,
|
||||||
|
viewTransition: 'md'
|
||||||
},
|
},
|
||||||
isMatch(p) {
|
isMatch(p) {
|
||||||
// "silk" is kindle fire
|
// "silk" is kindle fire
|
||||||
let re = 'android| silk';
|
return p.isPlatform('android', 'android| silk');
|
||||||
return p.isPlatform('android', re);
|
|
||||||
},
|
},
|
||||||
versionParser(p) {
|
versionParser(p) {
|
||||||
return p.matchUserAgentVersion(/Android (\d+).(\d+)?/);
|
return p.matchUserAgentVersion(/Android (\d+).(\d+)?/);
|
||||||
@ -75,9 +76,9 @@ Platform.register({
|
|||||||
settings: {
|
settings: {
|
||||||
mode: 'ios',
|
mode: 'ios',
|
||||||
iconMode: 'ios',
|
iconMode: 'ios',
|
||||||
viewTransition: 'ios',
|
|
||||||
tapPolyfill: true,
|
tapPolyfill: true,
|
||||||
keyboardScrollAssist: true
|
keyboardScrollAssist: true,
|
||||||
|
viewTransition: 'ios'
|
||||||
},
|
},
|
||||||
isMatch(p) {
|
isMatch(p) {
|
||||||
return p.isPlatform('ios', 'iphone|ipad|ipod');
|
return p.isPlatform('ios', 'iphone|ipad|ipod');
|
||||||
|
@ -2,16 +2,12 @@ import {Transition} from './transition';
|
|||||||
import {Animation} from '../animations/animation';
|
import {Animation} from '../animations/animation';
|
||||||
|
|
||||||
|
|
||||||
const DURATION = 600;
|
const DURATION = 300;
|
||||||
const EASING = 'cubic-bezier(0.36,0.66,0.04,1)';
|
const EASING = 'cubic-bezier(0.36,0.66,0.04,1)';
|
||||||
|
|
||||||
const OPACITY = 'opacity';
|
const TRANSLATEY = 'translateY';
|
||||||
const TRANSLATEX = 'translateX';
|
const OFF_BOTTOM = '5%';
|
||||||
|
|
||||||
const OFF_RIGHT = '100%';
|
|
||||||
const OFF_LEFT = '-33%';
|
|
||||||
const CENTER = '0%'
|
const CENTER = '0%'
|
||||||
const OFF_OPACITY = 0.8;
|
|
||||||
|
|
||||||
|
|
||||||
class MaterialTransition extends Transition {
|
class MaterialTransition extends Transition {
|
||||||
@ -23,71 +19,52 @@ class MaterialTransition extends Transition {
|
|||||||
this.duration(DURATION);
|
this.duration(DURATION);
|
||||||
this.easing(EASING);
|
this.easing(EASING);
|
||||||
|
|
||||||
// entering item moves to center
|
// entering item moves in bottom to center
|
||||||
this.enteringView
|
this.enteringView
|
||||||
.to(TRANSLATEX, CENTER)
|
.to(TRANSLATEY, CENTER)
|
||||||
.to(OPACITY, 1)
|
|
||||||
.before.setStyles({ zIndex: this.entering.index });
|
.before.setStyles({ zIndex: this.entering.index });
|
||||||
|
|
||||||
|
// entering title fades in
|
||||||
this.enteringTitle
|
this.enteringTitle
|
||||||
.fadeIn()
|
.fadeIn();
|
||||||
.to(TRANSLATEX, CENTER);
|
|
||||||
|
|
||||||
// leaving view moves off screen
|
// leaving view stays put
|
||||||
this.leavingView
|
this.leavingView
|
||||||
.from(TRANSLATEX, CENTER)
|
|
||||||
.from(OPACITY, 1)
|
|
||||||
.before.setStyles({ zIndex: this.leaving.index });
|
.before.setStyles({ zIndex: this.leaving.index });
|
||||||
|
|
||||||
|
// leaving title fades out
|
||||||
this.leavingTitle
|
this.leavingTitle
|
||||||
.from(TRANSLATEX, CENTER)
|
.fadeOut();
|
||||||
.from(OPACITY, 1);
|
|
||||||
|
|
||||||
// set properties depending on direction
|
// set properties depending on direction
|
||||||
if (opts.direction === 'back') {
|
if (opts.direction === 'back') {
|
||||||
// back direction
|
// back direction
|
||||||
this.enteringView
|
this.enteringView
|
||||||
.from(TRANSLATEX, OFF_LEFT)
|
.from(TRANSLATEY, CENTER);
|
||||||
.from(OPACITY, OFF_OPACITY)
|
|
||||||
.to(OPACITY, 1);
|
|
||||||
|
|
||||||
this.enteringTitle
|
|
||||||
.from(TRANSLATEX, OFF_LEFT);
|
|
||||||
|
|
||||||
this.leavingView
|
|
||||||
.to(TRANSLATEX, OFF_RIGHT)
|
|
||||||
.to(OPACITY, 1);
|
|
||||||
|
|
||||||
this.leavingTitle
|
this.leavingTitle
|
||||||
.to(TRANSLATEX, OFF_RIGHT)
|
.fadeOut();
|
||||||
.to(OPACITY, 0);
|
|
||||||
|
|
||||||
if (this.leaving.enableBack() && this.viewWidth() > 200) {
|
// leaving view goes center to bottom
|
||||||
|
this.leavingView
|
||||||
|
.fromTo(TRANSLATEY, CENTER, OFF_BOTTOM)
|
||||||
|
.fadeOut();
|
||||||
|
|
||||||
|
if (this.leaving.enableBack()) {
|
||||||
let leavingBackButtonText = new Animation(this.leaving.backButtonTextElement());
|
let leavingBackButtonText = new Animation(this.leaving.backButtonTextElement());
|
||||||
leavingBackButtonText.fromTo(TRANSLATEX, CENTER, (this.viewWidth() / 2) + 'px');
|
leavingBackButtonText.fadeOut();
|
||||||
this.leavingNavbar.add(leavingBackButtonText);
|
this.leavingNavbar.add(leavingBackButtonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// forward direction
|
// forward direction
|
||||||
this.enteringView
|
this.enteringView
|
||||||
.from(TRANSLATEX, OFF_RIGHT)
|
.from(TRANSLATEY, OFF_BOTTOM)
|
||||||
.from(OPACITY, 1);
|
.fadeIn();
|
||||||
|
|
||||||
this.enteringTitle
|
if (this.entering.enableBack()) {
|
||||||
.from(TRANSLATEX, OFF_RIGHT);
|
|
||||||
|
|
||||||
this.leavingView
|
|
||||||
.to(TRANSLATEX, OFF_LEFT)
|
|
||||||
.to(OPACITY, OFF_OPACITY);
|
|
||||||
|
|
||||||
this.leavingTitle
|
|
||||||
.to(TRANSLATEX, OFF_LEFT)
|
|
||||||
.to(OPACITY, 0);
|
|
||||||
|
|
||||||
if (this.entering.enableBack() && this.viewWidth() > 200) {
|
|
||||||
let enteringBackButtonText = new Animation(this.entering.backButtonTextElement());
|
let enteringBackButtonText = new Animation(this.entering.backButtonTextElement());
|
||||||
enteringBackButtonText.fromTo(TRANSLATEX, (this.viewWidth() / 2) + 'px', CENTER);
|
enteringBackButtonText.fadeIn();
|
||||||
this.enteringNavbar.add(enteringBackButtonText);
|
this.enteringNavbar.add(enteringBackButtonText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user