Skip to content

Instantly share code, notes, and snippets.

@0x00dec0de
Created March 2, 2015 17:02
Show Gist options
  • Save 0x00dec0de/d11ebf1eb9aa42b0c14f to your computer and use it in GitHub Desktop.
Save 0x00dec0de/d11ebf1eb9aa42b0c14f to your computer and use it in GitHub Desktop.
Animation when scrolling.
//Animate CSS + WayPoints javaScript Plugin
//Example: $(".element").animated("zoomInUp", "zoomOutDown");
//Author URL: http://webdesign-master.ru
(function($) {
$.fn.animated = function(inEffect, outEffect) {
$(this).css("opacity", "0").addClass("animated").waypoint(function(dir) {
if (dir === "down") {
$(this).removeClass(outEffect).addClass(inEffect).css("opacity", "1");
} else {
$(this).removeClass(inEffect).addClass(outEffect).css("opacity", "1");
};
}, {
offset: "80%"
}).waypoint(function(dir) {
if (dir === "down") {
$(this).removeClass(inEffect).addClass(outEffect).css("opacity", "1");
} else {
$(this).removeClass(outEffect).addClass(inEffect).css("opacity", "1");
};
}, {
offset: -$(window).height()
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment