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

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

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