提交 1f6933ac 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

添加 transition transform-translate 通过%比做动画示例

(cherry picked from commit 52bac8b7)
上级 d06d2d0a
......@@ -33,6 +33,10 @@
<text class="text">点击修改Transform</text>
<view class="base-style transition-transform" id="styleTransform" @click="changeTransform"></view>
</view>
<view class="container">
<text class="text">点击修改TransformTranslate</text>
<view class="base-style transition-transform" id="transformTranslate" @click="changeTransformTranslate"></view>
</view>
<view class="container">
<text class="text">点击修改Transform和宽</text>
<view class="base-style transition-transform-width" id="styleTransformWithWidth" @click="changeTransformWithWidth"></view>
......@@ -82,6 +86,8 @@
propertyStyleBackground: null as UniElement | null,
isTransitionStyleTransformWithOrigin: false,
styleTransformWithOrigin: null as UniElement | null,
styleTransformTranslate: null as UniElement | null,
isTransformTranslate: false
}
},
onReady() {
......@@ -96,6 +102,7 @@
this.propertyStyleBackground = uni.getElementById("propertyStyleBackground")
this.styleTransformWithOrigin = uni.getElementById("styleTransformWithOrigin")
this.styleTransformWithWidth = uni.getElementById("styleTransformWithWidth")
this.styleTransformTranslate = uni.getElementById("transformTranslate")
},
methods: {
changeWidthOrHeight() {
......@@ -159,6 +166,11 @@
)
this.isTransitionStyleTransform = !this.isTransitionStyleTransform
},
changeTransformTranslate() {
const translate = this.isTransformTranslate ? `translate(0%,0%)` : `translate(100%,0%)`
this.styleTransformTranslate?.style?.setProperty('transform', translate)
this.isTransformTranslate = !this.isTransformTranslate
},
changeTransformWithWidth() {
this.styleTransformWithWidth?.style?.setProperty("transform", this.isTransitionStyleTransformWithWidth
? 'rotate(0deg)'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册