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

增加 transition width 示例

上级 d9386505
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
<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>
</view> </view>
<view class="container">
<text class="text">点击修改宽度(递增)</text>
<view class="width-progress transition-width" id="widthProgress" @click="changeWidthProgress"></view>
</view>
<view class="container"> <view class="container">
<text class="text">点击修改Margin</text> <text class="text">点击修改Margin</text>
<view class="base-style transition-margin" id="styleMargin" @click="changeMargin"></view> <view class="base-style transition-margin" id="styleMargin" @click="changeMargin"></view>
...@@ -63,6 +67,8 @@ ...@@ -63,6 +67,8 @@
return { return {
isTranstionWidthOrHeight: false, isTranstionWidthOrHeight: false,
widthOrHeight: null as UniElement | null, widthOrHeight: null as UniElement | null,
widthProgress: null as UniElement | null,
progressWidth: 200,
isTranstionChangeMargin: false, isTranstionChangeMargin: false,
styleMargin: null as UniElement | null, styleMargin: null as UniElement | null,
isTransitionStylePadding: false, isTransitionStylePadding: false,
...@@ -87,6 +93,7 @@ ...@@ -87,6 +93,7 @@
}, },
onReady() { onReady() {
this.widthOrHeight = uni.getElementById("widthOrHeight") this.widthOrHeight = uni.getElementById("widthOrHeight")
this.widthProgress = uni.getElementById("widthProgress")
this.styleMargin = uni.getElementById("styleMargin") this.styleMargin = uni.getElementById("styleMargin")
this.stylePadding = uni.getElementById("stylePadding") this.stylePadding = uni.getElementById("stylePadding")
this.styleBackground = uni.getElementById("styleBackground") this.styleBackground = uni.getElementById("styleBackground")
...@@ -105,6 +112,10 @@ ...@@ -105,6 +112,10 @@
: '300px') : '300px')
this.isTranstionWidthOrHeight = !this.isTranstionWidthOrHeight this.isTranstionWidthOrHeight = !this.isTranstionWidthOrHeight
}, },
changeWidthProgress() {
this.progressWidth += 20
this.widthProgress?.style?.setProperty("width", this.progressWidth + 'px')
},
changeMargin() { changeMargin() {
this.styleMargin?.style?.setProperty("margin-top", this.isTranstionChangeMargin this.styleMargin?.style?.setProperty("margin-top", this.isTranstionChangeMargin
? '0px' ? '0px'
...@@ -216,6 +227,12 @@ ...@@ -216,6 +227,12 @@
background-color: brown; background-color: brown;
} }
.width-progress {
width: 200px;
height: 200px;
background-color: brown;
}
.transform-bgColor { .transform-bgColor {
transition-property: background-color; transition-property: background-color;
transition-duration: 0.5s; transition-duration: 0.5s;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册