movable-view組件(拖拽縮放)


1.wxml

<view>movable-view組件</view>
<view class='section'>
  <view class='section_title'>movable-view區域小於movable-area</view>
  <movable-area style='height:200rpx;width:200rpx;background:red;'>
    <movable-view style="height:50rpx;width:50rpx;background:yellow;" x='{{x}}' y='{{y}}' direction='all' inertia='true'></movable-view>
  </movable-area>
  <view class='btn-area'>
    <button size='mini' bindtap="tap">click me to move to(30rpx,30rpx)</button>
  </view>
  <view>movable區域大於movable-area</view>
  <movable-area style='height:100rpx;width:100rpx;background:red;'>
    <movable-view style="height:200rpx;width:200rpx;background:blue;" direction='all' bindchange='onchange' bindscale='onscale' scale scale-min='0.5' scale-max='4' scale-value='2'></movable-view>
  </movable-area>
</view>

2.JS

Page({
  data:{
    x:0,
    y:0
  },
  tap:function(e){
    this.setData({
      x:30,
      y:30
    });
  },
  onChange:function(e){
    console.log(e.detail);
  },
  onScale: function (e) {
    console.log(e.detail);
  }
})

 

 

 

感謝:https://www.bilibili.com/video/av61418389/?p=33

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM