From 6df9b95dea0be79c73d20781d2c24147c178a122 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Sat, 7 Mar 2015 19:38:48 +0100 Subject: [PATCH] Code style. NEW CPView -DOMElementForKeyPath:keyPath: -DOMElementForKeyPath:keyPath returns the DOMElement animated by the css Animation. This allow for an element different from the view _DOMElement to be animated. --- AppKit/CoreAnimation/CPAnimationContext.j | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/AppKit/CoreAnimation/CPAnimationContext.j b/AppKit/CoreAnimation/CPAnimationContext.j index 44c292911..da874752f 100644 --- a/AppKit/CoreAnimation/CPAnimationContext.j +++ b/AppKit/CoreAnimation/CPAnimationContext.j @@ -273,17 +273,23 @@ CPLog.debug(_cmd + "context stack =" + _CPAnimationContextStack); timingFunctions = anAction.timingfunctions, properties = [], valueFunctions = [], - createNewAnimation, - cssAnimation; + cssAnimation = nil; - var animIdx = [cssAnimations indexOfObjectPassingTest:function(anim, idx, stop) + [cssAnimations enumerateObjectsUsingBlock:function(anim, idx, stop) { - return (anim.identifier == identifier); + if (anim.identifier == identifier) + { + cssAnimation = anim; + stop(YES); + } }]; - createNewAnimation = (animIdx === CPNotFound); - - cssAnimation = createNewAnimation ? new CSSAnimation(aTargetView._DOMElement, identifier) : cssAnimations[animIdx]; + if (cssAnimation == nil) + { + var domElement = [aTargetView DOMElementForKeyPath:keyPath]; + cssAnimation = new CSSAnimation(domElement, identifier); + cssAnimations.push(cssAnimation); + } [[aTargetView class] getCSSProperties:properties valueFunctions:valueFunctions forKeyPath:keyPath]; @@ -296,9 +302,6 @@ CPLog.debug(_cmd + "context stack =" + _CPAnimationContextStack); if (needsFrameTimer) cssAnimation.setRemoveAnimationPropertyOnCompletion(false); - - if (createNewAnimation) - cssAnimations.push(cssAnimation); } if (needsFrameTimer)