微信小程序开发图片拖拽实例详解
1.编写页面结构:moveimg.wxml
<view class="container"> <view class="cnt"> <image class="image-style" src="/UploadFiles/2021-04-02/foods.jpg">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.设置数据: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 }); } })这几天一直在研究图片裁剪,思路是有,可是却遇到各种问题。可怜编程不易啊。
想了好久,决定还是简单开始吧。如果大家有更好的方式或是其他想法,欢迎提出,一起讨论。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
风云阁资源网 Design By www.bgabc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
风云阁资源网 Design By www.bgabc.com
暂无评论...
更新日志
2024年09月23日
2024年09月23日
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量编号[WAV+CUE]
- 曼丽2020《女人三十风继续吹》HQCD[WAV+CUE]
- 曼丽2021《女人三十2雾之恋》HQCD[WAV+CUE]
- 隔壁老樊.2019-我曾【好听音乐】【FLAC分轨】
- 高林生.1993-牵挂你的人是我【白天鹅】【WAV+CUE】
- 洪卓立.2012-找个懂我的女孩(国专)【英皇娱乐】【WAV+CUE】
- 曼丽2022《女人三十3晚秋》HQCD[WAV+CUE]
- 曼丽2018《女人三十4冬天》HQCD[WAV+CUE]
- 柏菲-《好歌30年壹》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 大自然音乐系列《水舞》[WAV/CUE/分轨][424.3MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]