cover-view实现悬浮球真机调试,拖动悬浮球时悬浮球一直抖动
.float-ball { position: fixed; width: 50px; height: 50px; bottom: 0px; right: 0px; } <cover-view class="float-ball" style="bottom: {{ballBottom}}px; right: {{ballRight}}px;" bindtap="ballClickEvent"catchtouchmove="catchBallMove"> <cover-image src="/images/icon" style="width: 100%; height: 100%;" mode="aspectFill" /> </cover-view> catchBallMove: function (e) { let touchs = e.touches[0]; let pageX = touchs.pageX; let pageY = touchs.pageY; let offSetY = _this.data.offSetY; let x = this.data.screenWidth - pageX - 25; let y = this.data.screenHeight - (pageY - offSetY) + 25; if(x < 0) { x = 0; } if(x > _this.data.screenWidth - 50) { x = _this.data.screenWidth - 50; } if(y < 45) { y = 45; } if(y > _this.data.screenHeight) { y = _this.data.screenHeight; } this.setData({ ballBottom: y, ballRight: x, }); },