MCPcopy Index your code
hub / github.com/SortableJS/Sortable / AnimationStateManager

Function AnimationStateManager

modular/sortable.complete.esm.js:539–668  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

SortableFunction · 0.70

Calls 8

cssFunction · 0.70
getRectFunction · 0.70
_objectSpread2Function · 0.70
matrixFunction · 0.70
indexOfObjectFunction · 0.70
isRectEqualFunction · 0.70
calculateRealTimeFunction · 0.70
repaintFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…