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