You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
removeTargets is pausing the seamless animation, since removeTargets will remove the children of the main instance. It may make sense to check that things are removed before removing a child or pausing an instance - I may be missing some limiting cases here, though...
THANKS!
I fixed the problem with the following code:
// Remove targets from animation
function removeTargetsFromAnimations(targetsArray, animations) {
var count = 0;
for (var a = animations.length; a--;) {
if (arrayContains(targetsArray, animations[a].animatable.target)) {
animations.splice(a, 1);
count++;
}
}
return count;
}
function removeTargets(targets) {
var targetsArray = parseTargets(targets);
for (var i = activeInstances.length; i--;) {
var instance = activeInstances[i];
var animations = instance.animations;
var children = instance.children;
var animationsRemoved = removeTargetsFromAnimations(targetsArray, animations);
var childAnimationsRemoved = 0;
for (var c = children.length; c--;) {
var child = children[c];
var childAnimations = child.animations;
childAnimationsRemoved = removeTargetsFromAnimations(targetsArray, childAnimations);
//Remove child only if child animations are removed and no children or animations exist
if (childAnimationsRemoved > 0 && !childAnimations.length && !child.children.length) {
children.splice(c, 1);
}
}
//Pause only if animations or child animations have been removed and no animations or children exist
if ((animationsRemoved > 0 || childAnimationsRemoved > 0) && !animations.length && !children.length) {
instance.pause();
}
}
}
The text was updated successfully, but these errors were encountered:
Tried example animation https://codepen.io/juliangarnier/pen/rGjMyW and then called removeTargets on a second animation.
removeTargets is pausing the seamless animation, since removeTargets will remove the children of the main instance. It may make sense to check that things are removed before removing a child or pausing an instance - I may be missing some limiting cases here, though...
THANKS!
I fixed the problem with the following code:
// Remove targets from animation
function removeTargetsFromAnimations(targetsArray, animations) {
var count = 0;
for (var a = animations.length; a--;) {
if (arrayContains(targetsArray, animations[a].animatable.target)) {
animations.splice(a, 1);
count++;
}
}
return count;
}
function removeTargets(targets) {
var targetsArray = parseTargets(targets);
for (var i = activeInstances.length; i--;) {
var instance = activeInstances[i];
var animations = instance.animations;
var children = instance.children;
var animationsRemoved = removeTargetsFromAnimations(targetsArray, animations);
var childAnimationsRemoved = 0;
for (var c = children.length; c--;) {
var child = children[c];
var childAnimations = child.animations;
childAnimationsRemoved = removeTargetsFromAnimations(targetsArray, childAnimations);
//Remove child only if child animations are removed and no children or animations exist
if (childAnimationsRemoved > 0 && !childAnimations.length && !child.children.length) {
children.splice(c, 1);
}
}
//Pause only if animations or child animations have been removed and no animations or children exist
if ((animationsRemoved > 0 || childAnimationsRemoved > 0) && !animations.length && !children.length) {
instance.pause();
}
}
}
The text was updated successfully, but these errors were encountered: