From 37fc59a357a1ce7a05f31cfe6f34946578ba2bba Mon Sep 17 00:00:00 2001 From: everdimension Date: Wed, 28 Oct 2015 18:57:59 +0300 Subject: [PATCH 1/2] use extraTransitionDuration from either defaults or the passed options to reveal it to public API --- src/cta.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cta.js b/src/cta.js index 31eb77b..cdba95a 100644 --- a/src/cta.js +++ b/src/cta.js @@ -97,8 +97,7 @@ triggerBackground, targetBounds, triggerBounds, - dummy, - extraTransitionDuration = 1; + dummy; // Support optional arguments if (typeof options === 'function') { @@ -109,6 +108,7 @@ options.duration = options.duration || defaults.duration; options.targetShowDuration = options.targetShowDuration || getAnimationTime(target) || defaults.targetShowDuration; options.relativeToWindow = options.relativeToWindow || defaults.relativeToWindow; + options.extraTransitionDuration = options.extraTransitionDuration || defaults.extraTransitionDuration; // Set some properties to make the target visible so we can get its dimensions. // Set `display` to `block` only when its already hidden. Otherwise changing an already visible @@ -168,11 +168,11 @@ callback(target); } // Animate the dummy element to zero opacity while the target is getting rendered. - dummy.style.transitionDuration = (options.targetShowDuration + extraTransitionDuration) + 's'; + dummy.style.transitionDuration = (options.targetShowDuration + options.extraTransitionDuration) + 's'; dummy.style.opacity = 0; setTimeout(function () { dummy.parentNode.removeChild(dummy); - }, (options.targetShowDuration + extraTransitionDuration) * 1000); + }, (options.targetShowDuration + options.extraTransitionDuration) * 1000); }); // Return a reverse animation function for the called animation. From 1da2c3445c2a761ae9daf2678ebeb3afc411dff5 Mon Sep 17 00:00:00 2001 From: everdimension Date: Wed, 28 Oct 2015 19:18:32 +0300 Subject: [PATCH 2/2] update readme accordingly --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c12765e..9f96ba5 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Animate an element `sourceElement` onto `targetElement`. * `options` - A map of additional options to control the animation behaviour. * `duration` - Duration (in seconds) of animation. Default is `0.3` seconds. * `targetShowDuration` - Duration (in seconds) of `targetElement` to become visible, if hidden initially. The library will automatically try to figure this out from the element's computed styles. Default is `0` seconds. + * `extraTransitionDuration` - Extra duration (in seconds) of `targetElement` to provide visual continuity between the animation and the rendering of the `targetElement`. Default is `1` second. * `relativeToWindow` - Set to true if your target element is fixed positioned in the window. Default is relative to document (works good with normal elements). * `callback` - Optional callback to execute after animation completes.