|
1393 | 1393 | var client,
|
1394 | 1394 | page,
|
1395 | 1395 | deltaSource = (target && target.options || defaultOptions).deltaSource,
|
1396 |
| - sourceX = deltaSource + 'X', |
1397 |
| - sourceY = deltaSource + 'Y', |
1398 |
| - options = target? target.options: defaultOptions, |
1399 |
| - origin = getOriginXY(target, element); |
| 1396 | + sourceX = deltaSource + 'X', |
| 1397 | + sourceY = deltaSource + 'Y', |
| 1398 | + options = target? target.options: defaultOptions, |
| 1399 | + origin = getOriginXY(target, element), |
| 1400 | + starting = phase === 'start', |
| 1401 | + ending = phase === 'end'; |
1400 | 1402 |
|
1401 | 1403 | element = element || target._element;
|
1402 | 1404 |
|
|
1417 | 1419 | client.x -= origin.x;
|
1418 | 1420 | client.y -= origin.y;
|
1419 | 1421 |
|
1420 |
| - if (checkSnap(target) && !(phase === 'start' && options.snap.elementOrigin)) { |
| 1422 | + if (checkSnap(target) && !(starting && options.snap.elementOrigin)) { |
1421 | 1423 |
|
1422 | 1424 | this.snap = {
|
1423 | 1425 | range : snapStatus.range,
|
|
1439 | 1441 | }
|
1440 | 1442 | }
|
1441 | 1443 |
|
1442 |
| - if (checkRestrict(target) && !(phase === 'start' && options.restrict.elementRect) && restrictStatus.restricted) { |
| 1444 | + if (checkRestrict(target) && !(starting && options.restrict.elementRect) && restrictStatus.restricted) { |
1443 | 1445 | page.x += restrictStatus.dx;
|
1444 | 1446 | page.y += restrictStatus.dy;
|
1445 | 1447 | client.x += restrictStatus.dx;
|
|
1456 | 1458 | this.clientX = client.x;
|
1457 | 1459 | this.clientY = client.y;
|
1458 | 1460 |
|
1459 |
| - if (phase === 'start' && !(event instanceof InteractEvent)) { |
| 1461 | + if (starting && !(event instanceof InteractEvent)) { |
1460 | 1462 | setEventXY(startCoords, this);
|
1461 | 1463 | }
|
1462 | 1464 |
|
|
1484 | 1486 | }
|
1485 | 1487 |
|
1486 | 1488 | // end event dx, dy is difference between start and end points
|
1487 |
| - if (phase === 'end' || action === 'drop') { |
| 1489 | + if (ending || action === 'drop') { |
1488 | 1490 | if (deltaSource === 'client') {
|
1489 | 1491 | this.dx = client.x - startCoords.clientX;
|
1490 | 1492 | this.dy = client.y - startCoords.clientY;
|
|
1544 | 1546 | ? [pointerMoves[0], pointerMoves[1]]
|
1545 | 1547 | : event.touches);
|
1546 | 1548 |
|
1547 |
| - if (phase === 'start') { |
| 1549 | + if (starting) { |
1548 | 1550 | this.distance = touchDistance(pointerMoves);
|
1549 | 1551 | this.box = touchBBox(pointerMoves);
|
1550 | 1552 | this.scale = 1;
|
1551 | 1553 | this.ds = 0;
|
1552 | 1554 | this.angle = touchAngle(pointerMoves);
|
1553 | 1555 | this.da = 0;
|
1554 | 1556 | }
|
1555 |
| - else if (phase === 'end' || event instanceof InteractEvent) { |
| 1557 | + else if (ending || event instanceof InteractEvent) { |
1556 | 1558 | this.distance = prevEvent.distance;
|
1557 | 1559 | this.box = prevEvent.box;
|
1558 | 1560 | this.scale = prevEvent.scale;
|
|
1571 | 1573 | }
|
1572 | 1574 | }
|
1573 | 1575 |
|
1574 |
| - if (phase === 'start') { |
| 1576 | + if (starting) { |
1575 | 1577 | this.timeStamp = downTime;
|
1576 | 1578 | this.dt = 0;
|
1577 | 1579 | this.duration = 0;
|
|
1597 | 1599 | // Use natural event coordinates (without snapping/restricions)
|
1598 | 1600 | // subtract modifications from previous event if event given is
|
1599 | 1601 | // not a native event
|
1600 |
| - if (phase === 'end' || event instanceof InteractEvent) { |
| 1602 | + if (ending || event instanceof InteractEvent) { |
1601 | 1603 | // change in time in seconds
|
1602 | 1604 | // use event sequence duration for end events
|
1603 | 1605 | // => average speed of the event sequence
|
1604 | 1606 | // (minimum dt of 1ms)
|
1605 |
| - dt = Math.max((phase === 'end'? this.duration: this.dt) / 1000, 0.001); |
| 1607 | + dt = Math.max((ending? this.duration: this.dt) / 1000, 0.001); |
1606 | 1608 | dx = this[sourceX] - prevEvent[sourceX];
|
1607 | 1609 | dy = this[sourceY] - prevEvent[sourceY];
|
1608 | 1610 |
|
|
1639 | 1641 | }
|
1640 | 1642 | }
|
1641 | 1643 |
|
1642 |
| - if ((phase === 'end' || phase === 'inertiastart') |
| 1644 | + if ((ending || phase === 'inertiastart') |
1643 | 1645 | && prevEvent.speed > 600 && this.timeStamp - prevEvent.timeStamp < 150) {
|
1644 | 1646 |
|
1645 | 1647 | var angle = 180 * Math.atan2(prevEvent.velocityY, prevEvent.velocityX) / Math.PI,
|
|
0 commit comments