UNPKG

formslider.dramatic.loader

Version:

This plugin adds animate.css capabilities to jquery.fromslider.

63 lines (53 loc) 2.57 kB
(function() { var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.DramaticLoader = (function(superClass) { extend(DramaticLoader, superClass); function DramaticLoader() { this.doAnimationOnNextSlide = bind(this.doAnimationOnNextSlide, this); this.finishAnimation = bind(this.finishAnimation, this); this.doAnimation = bind(this.doAnimation, this); return DramaticLoader.__super__.constructor.apply(this, arguments); } DramaticLoader.config = { duration: 2500, finishAnimationDuration: 2500, hideElementsOnHalf: '.hide-on-half', showElementsOnHalf: '.show-on-half', bounceOutOnHalf: '.bounce-out-on-half', bounceDownOnNext: '.bounce-down-on-enter' }; DramaticLoader.prototype.doAnimation = function() { var $elementsToBounceOut, $elementsToHide, $elementsToShow; this.on('leaving.next', this.doAnimationOnNextSlide); this.logger.debug("doAnimation(" + this.config.finishAnimationDuration + ")"); $elementsToHide = $(this.config.hideElementsOnHalf, this.slide); $elementsToShow = $(this.config.showElementsOnHalf, this.slide); $elementsToBounceOut = $(this.config.bounceOutOnHalf, this.slide); $elementsToHide.fadeOut().animateCss('bounceOut', 400, function() { return $elementsToShow.css({ display: 'block' }).fadeIn().animateCss('bounceIn', 500, function() { return $elementsToBounceOut.animateCss('bounceOut', 400).animate({ opacity: 0 }, 400); }); }); return setTimeout(this.finishAnimation, this.config.duration); }; DramaticLoader.prototype.finishAnimation = function() { return setTimeout(this.stop, this.config.finishAnimationDuration); }; DramaticLoader.prototype.doAnimationOnNextSlide = function(event, current, direction, next) { var $elementsToBounceDown; $elementsToBounceDown = $(this.config.bounceDownOnNext, next); return $elementsToBounceDown.css({ opacity: 0 }).animateCss('bounceInDown', 600).animate({ opacity: 1 }, 600); }; return DramaticLoader; })(AbstractFormsliderLoader); }).call(this);