tianyi 3 weeks ago
parent
commit
cc61f1c2f5
  1. 9
      uni_modules/uni-transition/changelog.md
  2. 70
      uni_modules/uni-transition/components/uni-transition/uni-transition.vue
  3. 102
      uni_modules/uni-transition/package.json

9
uni_modules/uni-transition/changelog.md

@ -1,3 +1,12 @@
## 1.3.6(2025-07-18)
- 修复 nvue 页面,样式错误问题
## 1.3.5(2025-06-11)
- 修复 第一次执行不显示动画的问题
## 1.3.4(2025-04-16)
- 修复 页面数据更新到底动画复原的问题
- 修复 示例页面打开报错的问题
## 1.3.3(2024-04-23)
- 修复 当元素会受变量影响自动隐藏的bug
## 1.3.2(2023-05-04) ## 1.3.2(2023-05-04)
- 修复 NVUE 平台报错的问题 - 修复 NVUE 平台报错的问题
## 1.3.1(2021-11-23) ## 1.3.1(2021-11-23)

70
uni_modules/uni-transition/components/uni-transition/uni-transition.vue

@ -1,9 +1,13 @@
<template> <template>
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view> <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
<slot></slot>
</view>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view> <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
<slot></slot>
</view>
<!-- #endif --> <!-- #endif -->
</template> </template>
@ -63,7 +67,7 @@ export default {
return { return {
isShow: false, isShow: false,
transform: '', transform: '',
opacity: 1, opacity: 0,
animationData: {}, animationData: {},
durationTime: 300, durationTime: 300,
config: {} config: {}
@ -136,18 +140,15 @@ export default {
* @param {Object} obj * @param {Object} obj
*/ */
step(obj, config = {}) { step(obj, config = {}) {
if (!this.animation) return if (!this.animation) return this
for (let i in obj) { Object.keys(obj).forEach(key => {
try { const value = obj[key]
if(typeof obj[i] === 'object'){ if (typeof this.animation[key] === 'function') {
this.animation[i](...obj[i]) Array.isArray(value) ?
}else{ this.animation[key](...value) :
this.animation[i](obj[i]) this.animation[key](value)
}
} catch (e) {
console.error(`方法 ${i} 不存在`)
}
} }
})
this.animation.step(config) this.animation.step(config)
return this return this
}, },
@ -161,24 +162,31 @@ export default {
// //
open() { open() {
clearTimeout(this.timer) clearTimeout(this.timer)
this.transform = ''
this.isShow = true this.isShow = true
let { opacity, transform } = this.styleInit(false) //
if (typeof opacity !== 'undefined') { this.transform = this.styleInit(false).transform || ''
this.opacity = opacity this.opacity = this.styleInit(false).opacity || 0
}
this.transform = transform
// nextTick wx // nextTick wx
this.$nextTick(() => { this.$nextTick(() => {
// TODO // TODO
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.animation = createAnimation(this.config, this) this.animation = createAnimation(this.config, this)
this.tranfromInit(false).step() this.tranfromInit(false).step()
this.animation.run() this.animation.run(() => {
// #ifdef APP-NVUE
this.transform = this.styleInit(false).transform || ''
this.opacity = this.styleInit(false).opacity || 1
// #endif
// #ifndef APP-NVUE
this.transform = ''
this.opacity = this.styleInit(false).opacity || 1
// #endif
this.$emit('change', { this.$emit('change', {
detail: this.isShow detail: this.isShow
}) })
}, 20) })
}, 80)
}) })
}, },
// //
@ -200,22 +208,20 @@ export default {
}, },
// //
styleInit(type) { styleInit(type) {
let styles = { let styles = { transform: '', opacity: 1 }
transform: '' const buildStyle = (type, mode) => {
} const value = this.animationType(type)[mode] // 使 type
let buildStyle = (type, mode) => { if (mode.startsWith('fade')) {
if (mode === 'fade') { styles.opacity = value
styles.opacity = this.animationType(type)[mode]
} else { } else {
styles.transform += this.animationType(type)[mode] + ' ' styles.transform += value + ' '
} }
} }
if (typeof this.modeClass === 'string') { if (typeof this.modeClass === 'string') {
buildStyle(type, this.modeClass) buildStyle(type, this.modeClass)
} else { } else {
this.modeClass.forEach(mode => { this.modeClass.forEach(mode => buildStyle(type, mode))
buildStyle(type, mode)
})
} }
return styles return styles
}, },

102
uni_modules/uni-transition/package.json

@ -1,7 +1,7 @@
{ {
"id": "uni-transition", "id": "uni-transition",
"displayName": "uni-transition 过渡动画", "displayName": "uni-transition 过渡动画",
"version": "1.3.2", "version": "1.3.6",
"description": "元素的简单过渡动画", "description": "元素的简单过渡动画",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -12,7 +12,9 @@
], ],
"repository": "https://github.com/dcloudio/uni-ui", "repository": "https://github.com/dcloudio/uni-ui",
"engines": { "engines": {
"HBuilderX": "" "HBuilderX": "",
"uni-app": "^4.12",
"uni-app-x": ""
}, },
"directories": { "directories": {
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
@ -35,48 +37,74 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue" "type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss"], "dependencies": [
"uni-scss"
],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "x",
"aliyun": "y" "aliyun": "x",
"alipay": "x"
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "y", "vue": {
"app-nvue": "y" "vue2": "√",
}, "vue3": "√"
"H5-mobile": { },
"Safari": "y", "web": {
"Android Browser": "y", "safari": "√",
"微信浏览器(Android)": "y", "chrome": "√"
"QQ浏览器(Android)": "y" },
}, "app": {
"H5-pc": { "vue": "√",
"Chrome": "y", "nvue": "√",
"IE": "y", "android": "√",
"Edge": "y", "ios": "√",
"Firefox": "y", "harmony": "√"
"Safari": "y" },
}, "mp": {
"小程序": { "weixin": {
"微信": "y", },
"阿里": "y", "alipay": {
"百度": "y", },
"字节跳动": "y", "toutiao": {
"QQ": "y" },
}, "baidu": {
"快应用": { },
"华为": "u", "kuaishou": {
"联盟": "u" },
}, "jd": {
"Vue": { },
"vue2": "y", "harmony": "-",
"vue3": "y" "qq": "√",
"lark": "-"
},
"quickapp": {
"huawei": "√",
"union": "√"
}
},
"uni-app-x": {
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
} }
} }
} }

Loading…
Cancel
Save