欧洲变态另类zozo,欧美xxxx做受欧美gaybdsm,欧洲熟妇色xxxx欧美老妇软件,免费人成视频xvideos入口 ,欧美.日韩.国产.中文字幕

歡迎光臨本站
我們一直在努力

微信小程序開發(fā)圖片拖拽

這篇文章主要介紹了微信小程序開發(fā)圖片拖拽實例詳解的相關資料,需要的朋友可以參考下

微信小程序開發(fā)圖片拖拽實例詳解

1.編寫頁面結構:moveimg.wxml

<view class="container"> 
  <view class="cnt"> 
    <image class="image-style" src="../uploads/foods.jpg" style="left:{{ballleft}}px;width:{{screenWidth}}px" bindtouchmove="ballMoveEvent"> 
    </image> 
  </view> 
</view>
登錄后復制

2.編寫頁面樣式:moveimg.wxss

.container { 
  box-sizing:border-box; 
  padding:1rem; 
} 
.cnt{ 
  width:100%; 
  height:15rem; 
  border: 1px solid #ccc; 
  position:relative; 
  overflow: hidden; 
} 
.image-style{  
  position: absolute;  
  top: 0px;  
  left:0px;  
  height:100%;  
}
登錄后復制

3.設置數(shù)據(jù):moveimg.js

var app = getApp() 
Page({ 
  data: { 
    ballleft:-20, 
    screenWidth: 0, 
  }, 
  onLoad: function() { 
    var _this = this; 
    wx.getSystemInfo({ 
      success: function(res) { 
        _this.setData({ 
          screenHeight: res.windowHeight, 
          screenWidth: res.windowWidth, 
        }); 
      } 
    }); 

  }, 
  ballMoveEvent: function(e) { 
    var touchs = e.touches[0]; 
    var pageX = touchs.pageX; 
    console.log('寬度 '+this.data.screenWidth) 
    console.log('pageX: ' + pageX); 
    //這里用right和bottom.所以需要將pageX pageY轉換  
    var x = this.data.screenWidth/2 - pageX-20; 
    if(this.data.screenWidth>385){ 
      if(x>42){x=42;} 
    }else{ 
      if(x>32){x=32;} 
    } 
    if(x<0){x=0;} 
    console.log('x:' + x) 
    this.setData({ 
      ballleft: -x 
    }); 
  } 
})
登錄后復制

   這幾天一直在研究圖片裁剪,思路是有,可是卻遇到各種問題??蓱z編程不易啊。

想了好久,決定還是簡單開始吧。如果大家有更好的方式或是其他想法,歡迎提出,一起討論。

以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網!

相關推薦:

以上就是微信小程序開發(fā)圖片拖拽的詳細內容,更多請關注有卡有網。

版權聲明:本文采用知識共享 署名4.0國際許可協(xié)議 [BY-NC-SA] 進行授權
文章名稱:《微信小程序開發(fā)圖片拖拽》
文章鏈接:http://www.ljxxtl.cn/kaquan-baike/xcx/154702.html
本站資源僅供個人學習交流,請于下載后24小時內刪除,不允許用于商業(yè)用途,否則法律問題自行承擔。