From 86a8a9dc859aca256b4790980db3e7cbedcb1762 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Tue, 26 Apr 2016 18:30:51 +0200 Subject: [PATCH] Fixed: The animation was reverting back to its initial position. Although the fill-mode property was correctly set to forwards allowing the final state to persist, the animation-name property was deleted too early . It was causing the animation to be cancelled and the initial state restored. --- AppKit/CoreAnimation/CPAnimationContext.j | 19 ++++---------- AppKit/CoreAnimation/CSSAnimation.j | 32 ++++++++++------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/AppKit/CoreAnimation/CPAnimationContext.j b/AppKit/CoreAnimation/CPAnimationContext.j index df87259e6..f39bf912c 100644 --- a/AppKit/CoreAnimation/CPAnimationContext.j +++ b/AppKit/CoreAnimation/CPAnimationContext.j @@ -163,9 +163,13 @@ CPLog.debug(_cmd + "context stack =" + _CPAnimationContextStack); { if (needsFrameTimer) [self stopFrameUpdaterWithIdentifier:objectId]; - else if (animationCompletion) + + if (animationCompletion) animationCompletion(); + if (needsFrameTimer || animationCompletion) + [[CPRunLoop currentRunLoop] performSelectors]; + if (_completionHandlerAgent) _completionHandlerAgent.decrement(); }; @@ -299,9 +303,6 @@ CPLog.debug(_cmd + "context stack =" + _CPAnimationContextStack); cssAnimation.addPropertyAnimation(property, getter, duration, anAction.keytimes, anAction.values, timingFunctions, completionFunction); }]; - - if (needsFrameTimer) - cssAnimation.setRemoveAnimationPropertyOnCompletion(false); } if (needsFrameTimer) @@ -640,17 +641,7 @@ FrameUpdater.prototype.start = function() FrameUpdater.prototype.stop = function() { -CPLog.debug("stop FrameUpdater with id " + this.identifier()); - this._stop = true; - - var targets = this._targets; - - for (var i = 0; i < targets.length; i++) - { - CPLog.debug(targets[i] + " Remove animation-name property"); - targets[i]._DOMElement.style.removeProperty(CPBrowserCSSProperty("animation-name")); - } }; FrameUpdater.prototype.updateFunction = function() diff --git a/AppKit/CoreAnimation/CSSAnimation.j b/AppKit/CoreAnimation/CSSAnimation.j index 31d0c8f7f..4350901a0 100644 --- a/AppKit/CoreAnimation/CSSAnimation.j +++ b/AppKit/CoreAnimation/CSSAnimation.j @@ -51,7 +51,6 @@ CSSAnimation = function(aTarget/*DOM Element*/, anIdentifier) this.animationsdurations = []; this.islive = false; this.didBuildDOMElements = false; - this.removeAnimationPropertyOnCompletion = true; animation = this; CURRENT_ANIMATIONS[anIdentifier] = animation; @@ -177,21 +176,21 @@ CSSAnimation.prototype.endEventListener = function() if (idx !== -1) inFlightAnimationsNames.splice(idx, 1); - if (inFlightAnimationsNames.length == 0) + if (inFlightAnimationsNames.length > 0) + return; + + for (var i = 0; i < animationsNames.length; i++) { - for (var i = 0; i < animationsNames.length; i++) - { - var completion = animation.completionFunctionForAnimationName(animationsNames[i]); - if (completion) - completion(); - } + var completion = animation.completionFunctionForAnimationName(animationsNames[i]); + if (completion) + completion(); + } - var eventTarget = event.target, - style = eventTarget.style; - - if (animation.removeAnimationPropertyOnCompletion) - style.removeProperty(ANIMATION_NAME_PROPERTY); + var eventTarget = event.target, + style = eventTarget.style; + try { + style.removeProperty(ANIMATION_NAME_PROPERTY); style.removeProperty(ANIMATION_DURATION_PROPERTY); style.removeProperty(ANIMATION_FILL_MODE_PROPERTY); style.removeProperty("-webkit-backface-visibility"); @@ -204,6 +203,8 @@ CSSAnimation.prototype.endEventListener = function() eventTarget.removeEventListener(ANIMATION_END_EVENT_NAME, AnimationEndListener); animation.listener = null; delete (CURRENT_ANIMATIONS[animation.identifier]); + } catch (err) { + CPLog.warn("CSSAnimation.j - " + err); } }; @@ -260,11 +261,6 @@ CSSAnimation.prototype.buildDOMElements = function() this.didBuildDOMElements = true; } -CSSAnimation.prototype.setRemoveAnimationPropertyOnCompletion = function(flag) -{ - this.removeAnimationPropertyOnCompletion = flag; -} - CSSAnimation.prototype.start = function() { if (this.propertyanimations.length == 0 || this.islive)