小程序可手指拖拽移动的小球

发布于:2023-06-27 ⋅ 阅读:(513) ⋅ 点赞:(0)
试读部分
<view class="suspend-btn" bindtap='addCollect' wx:if="{{write[0]+write[1] > 0}}" bindtouchmove="touchmove" catch:touchmove style="left:{{write[0]}}px;top:{{write[1]}}px;"> </view> ========== / 悬浮按钮样式 / .suspend-btn { position: absolute; z-index: 99; width: 80rpx; height: 80rpx; border-radius: 50%; background-color: red; } ====== Page({ data: { // 拖拽参数 writePosition: [80, 90], //默认定位参数 writesize: [0, 0],// X Y 定位 window: [0, 0], //屏幕尺寸 write: [0, 0], //定位参数 scrolltop: 0,//据顶部距离 }, onLoad: function (options) { // 在页面中定义插屏广告 let that = this; that.getSysdata(); }, //计算默认定位值 getSysdata: function () { var that = this; wx.getSystemInfo({ success: function (e) { that.data.window = [e.windowWidth, e.windowHeight]; var write = []; write[0] = that.data.window[0] * that.data.writePosition……
本文为 VIP 文章,已展示部分内容,开通 VIP 后查看全文

觉得这篇文章有帮助?

点个赞,或赞赏支持作者持续创作

微信公众号

今日签到

点亮在社区的每一天
去签到