From 5a2f9cd8aaadb99e55460bbfbd3909e5fb765964 Mon Sep 17 00:00:00 2001 From: luqianyu Date: Tue, 8 Dec 2020 17:25:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20animation=20+=20=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 4 +- pages/API/animation/animation.js | 87 +++++++++++++++++++ pages/API/animation/animation.json | 3 + pages/API/animation/animation.wxml | 46 ++++++++++ pages/API/animation/animation.wxss | 35 ++++++++ .../API/app-level-event/app-level-event.wxml | 4 +- pages/API/index/index.js | 8 ++ pages/API/menu-info/menu-info.js | 26 ++++++ pages/API/menu-info/menu-info.json | 3 + pages/API/menu-info/menu-info.wxml | 25 ++++++ pages/API/menu-info/menu-info.wxss | 7 ++ 11 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 pages/API/animation/animation.js create mode 100644 pages/API/animation/animation.json create mode 100644 pages/API/animation/animation.wxml create mode 100644 pages/API/animation/animation.wxss create mode 100644 pages/API/menu-info/menu-info.js create mode 100644 pages/API/menu-info/menu-info.json create mode 100644 pages/API/menu-info/menu-info.wxml create mode 100644 pages/API/menu-info/menu-info.wxss diff --git a/app.json b/app.json index 9f78913..d0b9bd5 100644 --- a/app.json +++ b/app.json @@ -50,7 +50,9 @@ "pages/API/load-font-face/load-font-face", "pages/API/video/video", "pages/API/audio/audio", - "pages/API/storage/storage" + "pages/API/storage/storage", + "pages/API/animation/animation", + "pages/API/menu-info/menu-info" ], "window": { "backgroundTextStyle": "light", diff --git a/pages/API/animation/animation.js b/pages/API/animation/animation.js new file mode 100644 index 0000000..5891d8f --- /dev/null +++ b/pages/API/animation/animation.js @@ -0,0 +1,87 @@ +Page({ + onShareAppMessage() { + return { + title: '动画', + path: 'page/API/pages/animation/animation', + containerStyle1: '', + + } + }, + + onReady() { + this.animation = wx.createAnimation() + }, + rotate() { + this.animation.rotate(Math.random() * 720 - 360).step() + this.setData({animation: this.animation.export()}) + }, + scale() { + this.animation.scale(Math.random() * 2).step() + this.setData({animation: this.animation.export()}) + }, + translate() { + this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step() + this.setData({animation: this.animation.export()}) + }, + skew() { + this.animation.skew(Math.random() * 90, Math.random() * 90).step() + this.setData({animation: this.animation.export()}) + }, + rotateAndScale() { + this.animation.rotate(Math.random() * 720 - 360) + .scale(Math.random() * 2) + .step() + this.setData({animation: this.animation.export()}) + }, + rotateThenScale() { + this.animation.rotate(Math.random() * 720 - 360).step() + .scale(Math.random() * 2).step() + this.setData({animation: this.animation.export()}) + }, + all() { + this.animation.rotate(Math.random() * 720 - 360) + .scale(Math.random() * 2) + .translate(Math.random() * 100 - 50, Math.random() * 100 - 50) + .skew(Math.random() * 90, Math.random() * 90) + .step() + this.setData({animation: this.animation.export()}) + }, + allInQueue() { + this.animation.rotate(Math.random() * 720 - 360).step() + .scale(Math.random() * 2).step() + .translate(Math.random() * 100 - 50, Math.random() * 100 - 50) + .step() + .skew(Math.random() * 90, Math.random() * 90) + .step() + this.setData({animation: this.animation.export()}) + }, + reset() { + this.animation.rotate(0, 0) + .scale(1) + .translate(0, 0) + .skew(0, 0) + .step({duration: 0}) + this.setData({animation: this.animation.export()}) + }, + change: function () { + this.animate('#container1', [ + { opacity: 1.0, rotate: 0, backgroundColor: '#FF0000' }, + { opacity: 0.5, rotate: 45, backgroundColor: '#00FF00', offset: 0.9}, + { opacity: 0.0, rotate: 90, backgroundColor: '#FF0000' }, + ], 5000, function () { + this.clearAnimation('#container1', { opacity: true, rotate: true }, function () { + console.log("清除了#container上的动画属性") + }) + }.bind(this)) + this.animate('.block1', [ + { scale: [1, 1], rotate: 0, ease: 'ease-out' }, + { scale: [1.5, 1.5], rotate: 45, ease: 'ease-in', offset: 0.9}, + { scale: [2, 2], rotate: 90}, + ], 5000, function () { + this.clearAnimation('.block1', { scale: true, rotate: true}, function () { + console.log("清除了.block1上的动画属性") + }) + }.bind(this) + ) + }, +}) \ No newline at end of file diff --git a/pages/API/animation/animation.json b/pages/API/animation/animation.json new file mode 100644 index 0000000..1351e16 --- /dev/null +++ b/pages/API/animation/animation.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "动画" +} diff --git a/pages/API/animation/animation.wxml b/pages/API/animation/animation.wxml new file mode 100644 index 0000000..9cce474 --- /dev/null +++ b/pages/API/animation/animation.wxml @@ -0,0 +1,46 @@ + + + + +