Skip to content

Commit

Permalink
add builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinchang committed Apr 3, 2015
1 parent ef166cd commit 0e2dc2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
41 changes: 23 additions & 18 deletions dist/cta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! cta.js - v0.1.0 - 2015-03-30
/*! cta.js - v0.2.0 - 2015-04-03
* http://kushagragour.in/lab/ctajs/
* Copyright (c) 2015 Kushagra Gour; Licensed MIT */

Expand Down Expand Up @@ -77,11 +77,13 @@

// Whether to position the dummy animating element relative to window (fixed positioned) or not.
relativeToWindow: false
}
};

function cta(trigger, target, options, callback) {
if (!isSupportedBrowser) {
callback && callback(target);
if (callback) {
callback(target);
}
return;
}

Expand Down Expand Up @@ -141,24 +143,27 @@
dummy.style.setProperty('transform', 'translate(' + diffX + 'px, ' + diffY + 'px) scale(' + scaleXRatio + ', ' + scaleYRatio + ')', 'important');
document.body.appendChild(dummy);

// We start animation on the next available frame.
requestAnimationFrame(function () {
dummy.style.setProperty('background', targetBackground, 'important');
// Trigger a layout to let styles apply.
var justReadIt = dummy.offsetTop;

// We reverting everything to lets things animate.
dummy.style.setProperty('background', targetBackground, 'important');

// Remove the reverse transforms to get the dummy transition back to its normal/final state.
dummy.style.removeProperty('transform');
// Remove the reverse transforms to get the dummy transition back to its normal/final state.
dummy.style.removeProperty('transform');

dummy.addEventListener('transitionend', function transitionEndCallback() {
dummy.removeEventListener('transitionend', transitionEndCallback);
dummy.addEventListener('transitionend', function transitionEndCallback() {
dummy.removeEventListener('transitionend', transitionEndCallback);

callback && callback(target);
// Animate the dummy element to zero opacity while the target is getting rendered.
dummy.style.transitionDuration = (options.targetShowDuration + extraTransitionDuration) + 's';
dummy.style.opacity = 0;
setTimeout(function () {
dummy.parentNode.removeChild(dummy);
}, (options.targetShowDuration + extraTransitionDuration) * 1000);
});
if (callback) {
callback(target);
}
// Animate the dummy element to zero opacity while the target is getting rendered.
dummy.style.transitionDuration = (options.targetShowDuration + extraTransitionDuration) + 's';
dummy.style.opacity = 0;
setTimeout(function () {
dummy.parentNode.removeChild(dummy);
}, (options.targetShowDuration + extraTransitionDuration) * 1000);
});

// Return a reverse animation function for the called animation.
Expand Down
4 changes: 2 additions & 2 deletions dist/cta.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0e2dc2f

Please sign in to comment.