var order = ['green', 'red', 'yellow', 'blue', 'green'] Page({ data: { toView: "green", s: 20, scrolltoupper: 'scrolltoupper', scrolltolower: 'scrolltolower', scroll: 'scroll', scrollLeft: 100, scrollTop: 0
}, onReady: function () { this.animation = wx.createAnimation() }, tap1: function () { var i = this.data.s += 20 console.log(this.data.s) this.animation.translateX(i).step(); this.setData({ animation: this.animation.export() }) }, upper: function (e) { console.log(e); this.setData({ scrolltoupper: JSON.stringify(e) }) }, lower: function (e) { console.log(e); this.setData({ scrolltolower: JSON.stringify(e) }) }, scroll: function (e) { console.log(e); this.setData({ scroll: JSON.stringify(e) }) }, scrollToTop: function (e) { this.setData({ scrollTop: 0 }) }, scrollToLeft: function (e) { this.setData({ scrollLeft: 0 }) }, tap: function (e) { for (var i = 0; i < order.length; ++i) { if (order[i] === this.data.toView) { this.setData({ toView: order[i + 1], scrollTop: (i + 1) * 200 }) break } } }, tap2: function (e) { for (var i = 0; i < order.length; ++i) { if (order[i] === this.data.toView) { this.setData({ toView: order[i + 1], scrollLeft: (i + 1) * 200 }) break } } }, tapMove: function (e) { this.setData({ scrollTop: this.data.scrollTop + 10 }) }, tapMove2: function (e) { this.setData({ scrollLeft: this.data.scrollLeft + 10 }) }, reset() { this.setData({ scrolltoupper: '---', scrolltolower: '---', scroll: '---'
}) } })
|