Bug
有多个movable-view ,bindscal始终触发示例中蓝色的movable-view放大缩小。且回调始终执行onScale1
,打印1。
* 如何复现? 代码如下
<movable-area style="height: 1206rpx; width: 100%; background: red;" scale-area>
<movable-view style="height: 50px; width: 50px; background: blue;" direction="all" bindchange="onChange" x="100" y="200" bindtap="onTap" bindscale="onScale1" scale scale-min="0.5" scale-max="4" scale-value="1">
</movable-view>
<movable-view style="height: 100px; width: 100px; background:green;" direction="all" bindchange="onChange" x="10" y="20" bindtap="onTap" bindscale="onScale2" scale scale-min="0.5" scale-max="4" scale-value="1">
</movable-view>
</movable-area>
.js
Page({
onChange: function (e) {
},
onScale1: function (e) {
console.log('1')
},
onScale2: function (e) {
console.log('2')
}
})
************解决方式
通过 scale="{{switch}}"
控制scale的状态,两个movable-view可以切换数据中switch的值控制哪一个组件触发。代码如下
.wxml
<movable-area style="height: 1206rpx; width: 100%; background: red;" scale-area>
<movable-view style="height: 50px; width: 50px; background: blue;" direction="all" bindchange="onChange" x="100" y="200" bindtap="onTap" bindscale="onScale1" scale="{{switc}}" scale-min="0.5" scale-max="4" scale-value="1">
</movable-view>
<movable-view style="height: 100px; width: 100px; background:green;" direction="all" bindchange="onChange" x="10" y="20" bindtap="onTap" bindscale="onScale2" scale="{{!switc}}" scale-min="0.5" scale-max="4" scale-value="1">
</movable-view>
</movable-area>
.js
Page({
data:{
switc:true},
onTap:function(){
var flag = this.data.switc
this.setData({
switc: !flag
})
}
})
嗯 是个办法
设置多个缩放, 始终缩放第一个