()
| 543 | var expando = 'Sortable' + new Date().getTime(); |
| 544 | |
| 545 | function AnimationStateManager() { |
| 546 | var animationStates = [], |
| 547 | animationCallbackId; |
| 548 | return { |
| 549 | captureAnimationState: function captureAnimationState() { |
| 550 | animationStates = []; |
| 551 | if (!this.options.animation) return; |
| 552 | var children = [].slice.call(this.el.children); |
| 553 | children.forEach(function (child) { |
| 554 | if (css(child, 'display') === 'none' || child === Sortable.ghost) return; |
| 555 | animationStates.push({ |
| 556 | target: child, |
| 557 | rect: getRect(child) |
| 558 | }); |
| 559 | var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); |
| 560 | |
| 561 | // If animating: compensate for current animation |
| 562 | if (child.thisAnimationDuration) { |
| 563 | var childMatrix = matrix(child, true); |
| 564 | if (childMatrix) { |
| 565 | fromRect.top -= childMatrix.f; |
| 566 | fromRect.left -= childMatrix.e; |
| 567 | } |
| 568 | } |
| 569 | child.fromRect = fromRect; |
| 570 | }); |
| 571 | }, |
| 572 | addAnimationState: function addAnimationState(state) { |
| 573 | animationStates.push(state); |
| 574 | }, |
| 575 | removeAnimationState: function removeAnimationState(target) { |
| 576 | animationStates.splice(indexOfObject(animationStates, { |
| 577 | target: target |
| 578 | }), 1); |
| 579 | }, |
| 580 | animateAll: function animateAll(callback) { |
| 581 | var _this = this; |
| 582 | if (!this.options.animation) { |
| 583 | clearTimeout(animationCallbackId); |
| 584 | if (typeof callback === 'function') callback(); |
| 585 | return; |
| 586 | } |
| 587 | var animating = false, |
| 588 | animationTime = 0; |
| 589 | animationStates.forEach(function (state) { |
| 590 | var time = 0, |
| 591 | target = state.target, |
| 592 | fromRect = target.fromRect, |
| 593 | toRect = getRect(target), |
| 594 | prevFromRect = target.prevFromRect, |
| 595 | prevToRect = target.prevToRect, |
| 596 | animatingRect = state.rect, |
| 597 | targetMatrix = matrix(target, true); |
| 598 | if (targetMatrix) { |
| 599 | // Compensate for current animation |
| 600 | toRect.top -= targetMatrix.f; |
| 601 | toRect.left -= targetMatrix.e; |
| 602 | } |
no test coverage detected
searching dependent graphs…