提交 6e7fb7ed 编写于 作者: W wanganxp

css的transition示例补充渐隐渐现

上级 b37c4f68
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
<!-- #endif --> <!-- #endif -->
<view>
<view class="container"> <view class="container">
<text class="text">点击修改宽度</text> <text class="text">点击修改宽度</text>
<view class="base-style transition-width" id="widthOrHeight" @click="changeWidthOrHeight"></view> <view class="base-style transition-width" id="widthOrHeight" @click="changeWidthOrHeight"></view>
...@@ -31,6 +30,10 @@ ...@@ -31,6 +30,10 @@
<view class="base-style transition-background" id="styleBackground2" @click="changeBackground2"></view> <view class="base-style transition-background" id="styleBackground2" @click="changeBackground2"></view>
</view> </view>
</view> </view>
<view class="container">
<text class="text">点击修改opacity渐隐渐现</text>
<view class="base-style transition-opacity" id="styleOpacity" @click="changeStyleOpacity"></view>
</view>
<view class="container"> <view class="container">
<text class="text">动态修改background-color和duration</text> <text class="text">动态修改background-color和duration</text>
<view class="base-style" id="propertyStyleBackground" @click="propertyChangeBackground"></view> <view class="base-style" id="propertyStyleBackground" @click="propertyChangeBackground"></view>
...@@ -45,7 +48,8 @@ ...@@ -45,7 +48,8 @@
</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>
</view> </view>
<view class="container" @click="changeTransformWithOrigin"> <view class="container" @click="changeTransformWithOrigin">
<text class="text">点击修改Transform(含transform-origin)</text> <text class="text">点击修改Transform(含transform-origin)</text>
...@@ -59,7 +63,6 @@ ...@@ -59,7 +63,6 @@
<text class="text">点击修改Position</text> <text class="text">点击修改Position</text>
<view class="base-style transition-position" id="stylePosition" @click="changestylePosition"></view> <view class="base-style transition-position" id="stylePosition" @click="changestylePosition"></view>
</view> </view>
</view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
...@@ -79,11 +82,13 @@ ...@@ -79,11 +82,13 @@
stylePadding: null as UniElement | null, stylePadding: null as UniElement | null,
isTransitionstyleBackground: false, isTransitionstyleBackground: false,
isTransitionstyleBackground2: false, isTransitionstyleBackground2: false,
isTransitionstyleOpacity: false,
styleBackground: null as UniElement | null, styleBackground: null as UniElement | null,
styleBackground2: null as UniElement | null, styleBackground2: null as UniElement | null,
styleOpacity: null as UniElement | null,
isTransitionStyleTransform: false, isTransitionStyleTransform: false,
styleTransform: null as UniElement | null, styleTransform: null as UniElement | null,
isTransitionStyleTransformWithWidth:false, isTransitionStyleTransformWithWidth: false,
styleTransformWithWidth: null as UniElement | null, styleTransformWithWidth: null as UniElement | null,
isTransitionstyleBorder: false, isTransitionstyleBorder: false,
styleBorder: null as UniElement | null, styleBorder: null as UniElement | null,
...@@ -105,6 +110,7 @@ ...@@ -105,6 +110,7 @@
this.stylePadding = uni.getElementById("stylePadding") this.stylePadding = uni.getElementById("stylePadding")
this.styleBackground = uni.getElementById("styleBackground") this.styleBackground = uni.getElementById("styleBackground")
this.styleBackground2 = uni.getElementById("styleBackground2") this.styleBackground2 = uni.getElementById("styleBackground2")
this.styleOpacity = uni.getElementById("styleOpacity")
this.styleTransform = uni.getElementById("styleTransform") this.styleTransform = uni.getElementById("styleTransform")
this.styleBorder = uni.getElementById("styleBorder") this.styleBorder = uni.getElementById("styleBorder")
this.stylePosition = uni.getElementById("stylePosition") this.stylePosition = uni.getElementById("stylePosition")
...@@ -163,6 +169,14 @@ ...@@ -163,6 +169,14 @@
) )
this.isTransitionstyleBackground2 = !this.isTransitionstyleBackground2 this.isTransitionstyleBackground2 = !this.isTransitionstyleBackground2
}, },
changeStyleOpacity() {
this.styleOpacity?.style?.setProperty("opacity", this.isTransitionstyleOpacity
? '1'
: '0'
)
this.styleOpacity?.style?.setProperty("transition-duration", "1000ms")
this.isTransitionstyleOpacity = !this.isTransitionstyleOpacity
},
propertyChangeBackground() { propertyChangeBackground() {
if (!this.isSetTransition) { if (!this.isSetTransition) {
this.propertyStyleBackground?.style?.setProperty("transition-property", "background-color") this.propertyStyleBackground?.style?.setProperty("transition-property", "background-color")
...@@ -271,6 +285,11 @@ ...@@ -271,6 +285,11 @@
transition-duration: 1s; transition-duration: 1s;
} }
.transition-opacity {
transition-property: opacity;
transition-duration: 1s;
}
.transition-transform { .transition-transform {
transition-property: transform; transition-property: transform;
transition-duration: 1s; transition-duration: 1s;
...@@ -289,6 +308,7 @@ ...@@ -289,6 +308,7 @@
transition-property: left; transition-property: left;
transition-duration: 1s; transition-duration: 1s;
} }
.transition-transform-width { .transition-transform-width {
transition-property: transform, width; transition-property: transform, width;
transition-duration: 1s; transition-duration: 1s;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册