最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2017年05月05日 10:37:41   投稿:lqh  
這篇文章主要介紹了微信小程序開發(fā)圖片拖拽實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

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

1.編寫頁(yè)面結(jié)構(gòu):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.編寫頁(yè)面樣式: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è)置數(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轉(zhuǎn)換  
    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 
    }); 
  } 
}) 

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

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

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論

皮山县| 博乐市| 景泰县| 寿宁县| 黄骅市| 平昌县| 莱阳市| 星座| 乳源| 长沙县| 师宗县| 光泽县| 永登县| 靖宇县| 博白县| 固原市| 泰和县| 壤塘县| 永登县| 西乌珠穆沁旗| 隆安县| 巩留县| 黔东| 卢龙县| 永丰县| 广丰县| 泾源县| 湾仔区| 辽阳市| 青阳县| 浦东新区| 福建省| 德兴市| 肇州县| 宁武县| 恭城| 广南县| 西充县| 鲁山县| 兴和县| 当雄县|