|
@@ -1,4 +1,7 @@
|
|
|
Component({
|
|
|
+ properties: {
|
|
|
+ radius: Number //半径 单位px
|
|
|
+ },
|
|
|
data: {
|
|
|
top: "550px",
|
|
|
left: "345px",
|
|
@@ -17,11 +20,11 @@ Component({
|
|
|
methods: {
|
|
|
viewTouchMove(e) {
|
|
|
let left = e.touches[0].pageX;
|
|
|
- if (left > 375) left = 375;
|
|
|
- if (left < 0) left = 0;
|
|
|
+ if (left > (375 - this.data.radius)) left = 375 - (this.data.radius / 2);
|
|
|
+ if (left < 0 + this.data.radius) left = 0 + this.data.radius;
|
|
|
let top = e.touches[0].pageY;
|
|
|
- if (top < 0) top = 0;
|
|
|
- if (top > this.data.viewHeight) top = this.data.viewHeight;
|
|
|
+ if (top < 0 + this.data.radius) top = 0 + this.data.radius;
|
|
|
+ if (top > this.data.viewHeight - this.data.radius) top = this.data.viewHeight - this.data.radius;
|
|
|
this.setData({
|
|
|
left: left + 'px',
|
|
|
top: top + 'px'
|