mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
refactor(nav-viewport): rename animations to avoid confusion
This commit is contained in:
@ -11,28 +11,28 @@
|
||||
}
|
||||
&[animate] {
|
||||
display: block;
|
||||
transition: 1s linear;
|
||||
transition: 0.3s linear;
|
||||
}
|
||||
|
||||
&[animate=push-enter] {
|
||||
&[animate=enter] {
|
||||
transform: translate3d(100%,0,0);
|
||||
&.start {
|
||||
transform: translate3d(0,0,0);
|
||||
}
|
||||
}
|
||||
&[animate=pop-enter] {
|
||||
&[animate=enter-reverse] {
|
||||
transform: translate3d(-100%,0,0);
|
||||
&.start {
|
||||
transform: translate3d(0,0,0);
|
||||
}
|
||||
}
|
||||
&[animate=push-leave] {
|
||||
&[animate=leave-reverse] {
|
||||
transform: translate3d(0,0,0);
|
||||
&.start {
|
||||
transform: translate3d(-100%,0,0);
|
||||
}
|
||||
}
|
||||
&[animate=pop-leave] {
|
||||
&[animate=leave] {
|
||||
transform: translate3d(0,0,0);
|
||||
&.start {
|
||||
transform: translate3d(100%,0,0);
|
||||
|
||||
@ -6,33 +6,34 @@ import {array as arrayUtil, dom as domUtil} from 'ionic2/util'
|
||||
@Component({
|
||||
selector: 'ion-nav-viewport',
|
||||
bind: {
|
||||
initial: 'initial'
|
||||
initialComponent: 'initialComponent'
|
||||
},
|
||||
})
|
||||
@Template({
|
||||
inline: `
|
||||
<section class="nav-view" *for="#item of creator._array" [item]="item">
|
||||
<section class="nav-view" *for="#item of _ngForLoopArray" [item]="item">
|
||||
</section>
|
||||
`,
|
||||
directives: [NavView, For]
|
||||
})
|
||||
export class NavViewport {
|
||||
constructor() {
|
||||
// stack is our public stack of items. This is synchronous and says an item
|
||||
// is removed even if it's still animating out.
|
||||
this.stack = []
|
||||
this.creator = new ItemCreator()
|
||||
|
||||
// _ngForLoopArray is our loop that actually adds/removes components. It doesn't
|
||||
// remove a component until it's done animating out.
|
||||
this._ngForLoopArray = []
|
||||
}
|
||||
|
||||
set initial(Class) {
|
||||
set initialComponent(Class) {
|
||||
if (!this.initialized) {
|
||||
this.initialized = true
|
||||
this.push(Class)
|
||||
}
|
||||
}
|
||||
|
||||
getAnimation(opts) {
|
||||
return 'fade'
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a new view into the history stack.
|
||||
*
|
||||
@ -46,10 +47,11 @@ export class NavViewport {
|
||||
push(Class, opts = {}) {
|
||||
let item = new NavItem(Class, opts)
|
||||
this.stack.push(item)
|
||||
return this.creator.instantiate(item).then(() => {
|
||||
this._ngForLoopArray.push(item)
|
||||
return item.waitForSetup().then(() => {
|
||||
let current = this.getPrevious(item)
|
||||
current && current.pushLeave()
|
||||
return item.pushEnter()
|
||||
current && current.leaveReverse()
|
||||
return item.enter()
|
||||
})
|
||||
}
|
||||
|
||||
@ -61,9 +63,10 @@ export class NavViewport {
|
||||
pop() {
|
||||
let current = this.stack.pop()
|
||||
let previous = this.stack[this.stack.length - 1]
|
||||
previous.popEnter()
|
||||
current.popLeave().then(() => {
|
||||
this.creator.destroy(current)
|
||||
previous.enterReverse()
|
||||
return current.leave().then(() => {
|
||||
// The animation is done, remove it from the dom
|
||||
arrayUtil.remove(this._ngForLoopArray, current)
|
||||
})
|
||||
}
|
||||
|
||||
@ -135,17 +138,17 @@ class NavItem {
|
||||
})
|
||||
})
|
||||
}
|
||||
pushEnter() {
|
||||
return this._animate({ isShown: true, animation: 'push-enter' })
|
||||
enter() {
|
||||
return this._animate({ isShown: true, animation: 'enter' })
|
||||
}
|
||||
popEnter() {
|
||||
return this._animate({ isShown: true, animation: 'pop-enter' })
|
||||
enterReverse() {
|
||||
return this._animate({ isShown: true, animation: 'enter-reverse' })
|
||||
}
|
||||
pushLeave() {
|
||||
return this._animate({ isShown: false, animation: 'push-leave' })
|
||||
leave() {
|
||||
return this._animate({ isShown: false, animation: 'leave' })
|
||||
}
|
||||
popLeave() {
|
||||
return this._animate({ isShown: false, animation: 'pop-leave' })
|
||||
leaveReverse() {
|
||||
return this._animate({ isShown: false, animation: 'leave-reverse' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
<ion-nav-viewport [initial]="initial">
|
||||
<ion-nav-viewport [initial-component]="initial">
|
||||
</ion-nav-viewport>
|
||||
|
||||
@ -1,19 +1,15 @@
|
||||
import {NgElement, Component, Template, Foreach, Parent} from 'angular2/angular2';
|
||||
import {ComponentConfig} from 'ionic2/config/component-config';
|
||||
|
||||
export let TabsConfig = new ComponentConfig('tabs');
|
||||
|
||||
import {NgElement, Component, Template, Foreach, Parent} from 'angular2/angular2'
|
||||
import {NavViewport} from 'ionic2/components'
|
||||
import {IonicComponent} from 'ionic2/config/component'
|
||||
|
||||
@Component({
|
||||
selector: 'ion-tabs',
|
||||
bind: {
|
||||
tabBarPlacement: 'tab-bar-placement'
|
||||
placement: 'placement'
|
||||
},
|
||||
services: [TabsConfig]
|
||||
})
|
||||
@Template({
|
||||
inline: `
|
||||
|
||||
<div class="toolbar tab-bar toolbar-ios toolbar-bottom">
|
||||
<div class="tab-bar-content">
|
||||
<a class="tab-bar-item tab-active" href="#">
|
||||
@ -27,23 +23,28 @@ export let TabsConfig = new ComponentConfig('tabs');
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pane-container">
|
||||
<div class="content">
|
||||
<content></content>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
directives: []
|
||||
})
|
||||
export class Tabs {
|
||||
export class Tabs extends NavViewport {
|
||||
constructor(
|
||||
configFactory: TabsConfig,
|
||||
element: NgElement
|
||||
) {
|
||||
super()
|
||||
this.domElement = element.domElement
|
||||
this.domElement.classList.add('pane')
|
||||
configFactory.create(this)
|
||||
|
||||
this.tabBarPlacement = this.tabBarPlacement || 'bottom'
|
||||
this.config = Tabs.config.invoke(this)
|
||||
}
|
||||
}
|
||||
|
||||
new IonicComponent(Tabs, {
|
||||
bind: {
|
||||
placement: {
|
||||
defaults: {
|
||||
ios: 'bottom',
|
||||
android: 'top',
|
||||
base: 'bottom'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -60,7 +60,6 @@ var ua = window.navigator.userAgent
|
||||
platform.register({
|
||||
name: 'android',
|
||||
matcher() {
|
||||
//TODO Make a better override than window
|
||||
return queryPlatform == 'android' || /android/i.test(ua)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user