提交 7b4d0d86 编写于 作者: D DCloud_LXH

fix(app): navigator animationType animationDuration question/143377

上级 96a5b6ad
<template> <template>
<uni-navigator <uni-navigator
v-if="hoverClass && hoverClass !== 'none'" v-if="hoverClass && hoverClass !== 'none'"
:class="[hovering ? hoverClass : '']" :class="[hovering ? hoverClass : '']"
@touchstart="_hoverTouchStart" @touchstart="_hoverTouchStart"
@touchend="_hoverTouchEnd" @touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel" @touchcancel="_hoverTouchCancel"
@click="_onClick" @click="_onClick"
v-on="$listeners" v-on="$listeners"
> >
<slot /> <slot />
</uni-navigator> </uni-navigator>
<uni-navigator <uni-navigator
v-else v-else
@click="_onClick" @click="_onClick"
v-on="$listeners" v-on="$listeners"
> >
<slot /> <slot />
</uni-navigator> </uni-navigator>
...@@ -23,7 +23,35 @@ import { ...@@ -23,7 +23,35 @@ import {
hover hover
} from 'uni-mixins' } from 'uni-mixins'
const OPEN_TYPES = ['navigate', 'redirect', 'switchTab', 'reLaunch', 'navigateBack'] const OPEN_TYPES = [
'navigate',
'redirect',
'switchTab',
'reLaunch',
'navigateBack'
]
const ANIMATION_TYPE_IN = [
'slide-in-right',
'slide-in-left',
'slide-in-top',
'slide-in-bottom',
'fade-in',
'zoom-out',
'zoom-fade-out',
'pop-in',
'none'
]
const ANIMATION_TYPE_OUT = [
'slide-out-right',
'slide-out-left',
'slide-out-top',
'slide-out-bottom',
'fade-out',
'zoom-in',
'zoom-fade-in',
'pop-out',
'none'
]
export default { export default {
name: 'Navigator', name: 'Navigator',
...@@ -50,7 +78,7 @@ export default { ...@@ -50,7 +78,7 @@ export default {
}, },
hoverStartTime: { hoverStartTime: {
type: [Number, String], type: [Number, String],
default: 20 default: 50
}, },
hoverStayTime: { hoverStayTime: {
type: [Number, String], type: [Number, String],
...@@ -59,6 +87,16 @@ export default { ...@@ -59,6 +87,16 @@ export default {
exists: { exists: {
type: String, type: String,
default: '' default: ''
},
animationType: {
type: String,
validator (value) {
return !value || ~ANIMATION_TYPE_IN.concat(ANIMATION_TYPE_OUT).indexOf(value)
}
},
animationDuration: {
type: [String, Number],
default: 300
} }
}, },
...@@ -70,10 +108,14 @@ export default { ...@@ -70,10 +108,14 @@ export default {
return return
} }
const animationDuration = parseInt(this.animationDuration)
switch (this.openType) { switch (this.openType) {
case 'navigate': case 'navigate':
uni.navigateTo({ uni.navigateTo({
url: this.url url: this.url,
animationType: this.animationType || 'pop-in',
animationDuration
}) })
break break
case 'redirect': case 'redirect':
...@@ -94,7 +136,9 @@ export default { ...@@ -94,7 +136,9 @@ export default {
break break
case 'navigateBack': case 'navigateBack':
uni.navigateBack({ uni.navigateBack({
delta: this.delta delta: this.delta,
animationType: this.animationType || 'pop-out',
animationDuration
}) })
break break
default: default:
...@@ -120,4 +164,4 @@ export default { ...@@ -120,4 +164,4 @@ export default {
background-color: rgba(0, 0, 0, 0.1); background-color: rgba(0, 0, 0, 0.1);
opacity: 0.7; opacity: 0.7;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册