|
62 | 62 | _target.addEventListener('touchleave', _handleLeave);
|
63 | 63 | _target.addEventListener('touchmove', _handleMove);
|
64 | 64 |
|
| 65 | + function position(e) { |
| 66 | + var offset = sigma.utils.getOffset(_target); |
| 67 | + |
| 68 | + return { |
| 69 | + x: e.pageX - offset.left, |
| 70 | + y: e.pageY - offset.top |
| 71 | + }; |
| 72 | + } |
65 | 73 |
|
66 | 74 |
|
67 | 75 |
|
|
78 | 86 | var x0,
|
79 | 87 | x1,
|
80 | 88 | y0,
|
81 |
| - y1; |
| 89 | + y1, |
| 90 | + pos0, |
| 91 | + pos1; |
82 | 92 |
|
83 | 93 | _downTouches = e.touches;
|
84 | 94 |
|
|
93 | 103 | _lastCameraX = _camera.x;
|
94 | 104 | _lastCameraY = _camera.y;
|
95 | 105 |
|
96 |
| - _startTouchX0 = sigma.utils.getX(_downTouches[0]); |
97 |
| - _startTouchY0 = sigma.utils.getY(_downTouches[0]); |
| 106 | + pos0 = position(_downTouches[0]); |
| 107 | + _startTouchX0 = pos0.x; |
| 108 | + _startTouchY0 = pos0.y; |
98 | 109 |
|
99 | 110 | break;
|
100 | 111 | case 2:
|
101 | 112 | _camera.isMoving = true;
|
102 | 113 | _touchMode = 2;
|
103 | 114 |
|
104 |
| - x0 = sigma.utils.getX(_downTouches[0]); |
105 |
| - y0 = sigma.utils.getY(_downTouches[0]); |
106 |
| - x1 = sigma.utils.getX(_downTouches[1]); |
107 |
| - y1 = sigma.utils.getY(_downTouches[1]); |
| 115 | + pos0 = position(_downTouches[0]); |
| 116 | + pos1 = position(_downTouches[1]); |
| 117 | + x0 = pos0.x; |
| 118 | + y0 = pos0.y; |
| 119 | + x1 = pos1.x; |
| 120 | + y1 = pos1.y; |
108 | 121 |
|
109 | 122 | _lastCameraX = _camera.x;
|
110 | 123 | _lastCameraY = _camera.y;
|
|
209 | 222 | cos,
|
210 | 223 | sin,
|
211 | 224 | end,
|
| 225 | + pos0, |
| 226 | + pos1, |
212 | 227 | diff,
|
213 | 228 | start,
|
214 | 229 | dAngle,
|
|
230 | 245 |
|
231 | 246 | switch (_touchMode) {
|
232 | 247 | case 1:
|
233 |
| - x0 = sigma.utils.getX(_downTouches[0]); |
234 |
| - y0 = sigma.utils.getY(_downTouches[0]); |
| 248 | + pos0 = position(_downTouches[0]); |
| 249 | + x0 = pos0.x; |
| 250 | + y0 = pos0.y; |
235 | 251 |
|
236 | 252 | diff = _camera.cameraPosition(
|
237 | 253 | x0 - _startTouchX0,
|
|
255 | 271 | }
|
256 | 272 | break;
|
257 | 273 | case 2:
|
258 |
| - x0 = sigma.utils.getX(_downTouches[0]); |
259 |
| - y0 = sigma.utils.getY(_downTouches[0]); |
260 |
| - x1 = sigma.utils.getX(_downTouches[1]); |
261 |
| - y1 = sigma.utils.getY(_downTouches[1]); |
| 274 | + pos0 = position(_downTouches[0]); |
| 275 | + pos1 = position(_downTouches[1]); |
| 276 | + x0 = pos0.x; |
| 277 | + y0 = pos0.y; |
| 278 | + x1 = pos1.x; |
| 279 | + y1 = pos1.y; |
262 | 280 |
|
263 | 281 | start = _camera.cameraPosition(
|
264 | 282 | (_startTouchX0 + _startTouchX1) / 2 - e.target.width / 2,
|
|
0 commit comments