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

fix(app): navigator animationType animationDuration question/143377

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