JavaScript animation engine
Improve remove()
Julian Garnier39007cfbebea
diff --git a/anime.js b/anime.jsindex a126603f..8258fdbd 100644--- a/anime.js+++ b/anime.js@@ -665,18 +665,22 @@const animations = instance.animations;for (let a = animations.length; a--;) {const animation = animations[a];- if ((propertyName && (animation.property === propertyName)) && instance.animatables.some(t => t.target === target)) {- animations.splice(a, 1);- if (!animations.length) instance.pause();- }+ const prop = propertyName ? (animation.property === propertyName) : true;+ console.log(propertyName, (animation.property === propertyName));+ if (prop && instance.animatables.some(t => t.target === target)) {+ console.log('hai');+ animations.splice(a, 1);+ if (!animations.length) instance.pause();+ }}}}- function removeTargets(targets) {+ function removeTargets(targets, propertyName) {const targetsArray = parseTargets(targets);- for (let i = targets.length; i--;) {- removeAnimation(targets[i]);+ for (let i = targetsArray.length; i--;) {+ console.log(targetsArray[i]);+ removeAnimation(targetsArray[i], propertyName);}}diff --git a/documentation/examples/anime-tests.html b/documentation/examples/anime-tests.htmlindex 65425300..7be53013 100644--- a/documentation/examples/anime-tests.html+++ b/documentation/examples/anime-tests.html@@ -41,21 +41,26 @@<div class="item color-02"></div><div class="item color-03"></div><script>- var anim = anime({+ anime({targets: '.color-01',backgroundColor: '#BAD',direction: 'alternate',easing: 'linear',- translateX: 50,+ // translateX: 50,loop: true});- var anim = anime({+ anime({targets: '.color-02',scale: 2,opacity: .5,loop: true});- console.log(anim);+ anime({+ targets: '.color-03',+ scale: 2,+ opacity: .5,+ loop: true+ });function mouseenter(e) {var anim = anime({targets: this,@@ -71,9 +76,9 @@opacity: 1})}- var el = document.querySelector('.color-01');- el.addEventListener('mouseenter', mouseenter, false);- el.addEventListener('mouseleave', mouseleave, false);+ var el01 = document.querySelector('.color-01');+ el01.addEventListener('mouseenter', mouseenter, false);+ el01.addEventListener('mouseleave', mouseleave, false);</script></body></html>\ No newline at end of file