From 6e7fb7ed901a8958120eb37c035a4ee19c1a037d Mon Sep 17 00:00:00 2001 From: wanganxp Date: Mon, 27 May 2024 04:15:20 +0800 Subject: [PATCH] =?UTF-8?q?css=E7=9A=84transition=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B8=90=E9=9A=90=E6=B8=90=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/CSS/transition/transition.uvue | 132 +++++++++++++++------------ 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/pages/CSS/transition/transition.uvue b/pages/CSS/transition/transition.uvue index 457df7bd..623fa851 100644 --- a/pages/CSS/transition/transition.uvue +++ b/pages/CSS/transition/transition.uvue @@ -2,64 +2,67 @@ - - - 点击修改宽度 - - - - 点击修改宽度(递增) - - - - 点击修改Margin - - - - 点击修改Padding - - - - - - 点击修改background-color和opacity - - - - 点击修改background-color(rgba) - - - - - - 动态修改background-color和duration - - - - 点击修改Transform - - - - 点击修改TransformTranslate - - - - 点击修改Transform和宽 - - - - 点击修改Transform(含transform-origin) - - - - 点击修改Border - + + 点击修改宽度 + + + + 点击修改宽度(递增) + + + + 点击修改Margin + + + + 点击修改Padding + + - - 点击修改Position - + + + 点击修改background-color和opacity + + + + 点击修改background-color(rgba) + + + + 点击修改opacity渐隐渐现 + + + + 动态修改background-color和duration + + + + 点击修改Transform + + + + 点击修改TransformTranslate + + + + 点击修改Transform和宽 + + + + 点击修改Transform(含transform-origin) + + + + 点击修改Border + + + + 点击修改Position + + @@ -79,11 +82,13 @@ stylePadding: null as UniElement | null, isTransitionstyleBackground: false, isTransitionstyleBackground2: false, + isTransitionstyleOpacity: false, styleBackground: null as UniElement | null, styleBackground2: null as UniElement | null, + styleOpacity: null as UniElement | null, isTransitionStyleTransform: false, styleTransform: null as UniElement | null, - isTransitionStyleTransformWithWidth:false, + isTransitionStyleTransformWithWidth: false, styleTransformWithWidth: null as UniElement | null, isTransitionstyleBorder: false, styleBorder: null as UniElement | null, @@ -105,6 +110,7 @@ this.stylePadding = uni.getElementById("stylePadding") this.styleBackground = uni.getElementById("styleBackground") this.styleBackground2 = uni.getElementById("styleBackground2") + this.styleOpacity = uni.getElementById("styleOpacity") this.styleTransform = uni.getElementById("styleTransform") this.styleBorder = uni.getElementById("styleBorder") this.stylePosition = uni.getElementById("stylePosition") @@ -163,6 +169,14 @@ ) 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() { if (!this.isSetTransition) { this.propertyStyleBackground?.style?.setProperty("transition-property", "background-color") @@ -271,6 +285,11 @@ transition-duration: 1s; } + .transition-opacity { + transition-property: opacity; + transition-duration: 1s; + } + .transition-transform { transition-property: transform; transition-duration: 1s; @@ -289,6 +308,7 @@ transition-property: left; transition-duration: 1s; } + .transition-transform-width { transition-property: transform, width; transition-duration: 1s; -- GitLab