(function() { var mutationobserver, util, weakmap, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __indexof = [].indexof || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; util = (function() { function util() {} util.prototype.extend = function(custom, defaults) { var key, value; for (key in defaults) { value = defaults[key]; if (custom[key] == null) { custom[key] = value; } } return custom; }; util.prototype.ismobile = function(agent) { return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(agent); }; return util; })(); weakmap = this.weakmap || this.mozweakmap || (weakmap = (function() { function weakmap() { this.keys = []; this.values = []; } weakmap.prototype.get = function(key) { var i, item, _i, _len, _ref; _ref = this.keys; for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { item = _ref[i]; if (item === key) { return this.values[i]; } } }; weakmap.prototype.set = function(key, value) { var i, item, _i, _len, _ref; _ref = this.keys; for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { item = _ref[i]; if (item === key) { this.values[i] = value; return; } } this.keys.push(key); return this.values.push(value); }; return weakmap; })()); mutationobserver = this.mutationobserver || this.webkitmutationobserver || this.mozmutationobserver || (mutationobserver = (function() { function mutationobserver() { console.warn('mutationobserver is not supported by your browser.'); console.warn('wow.js cannot detect dom mutations, please call .sync() after loading new content.'); } mutationobserver.notsupported = true; mutationobserver.prototype.observe = function() {}; return mutationobserver; })()); this.wow = (function() { wow.prototype.defaults = { boxclass: 'wow', animateclass: 'animated', offset: 0, mobile: true, live: true }; function wow(options) { if (options == null) { options = {}; } this.scrollcallback = __bind(this.scrollcallback, this); this.scrollhandler = __bind(this.scrollhandler, this); this.start = __bind(this.start, this); this.scrolled = true; this.config = this.util().extend(options, this.defaults); this.animationnamecache = new weakmap(); } wow.prototype.init = function() { var _ref; this.element = window.document.documentelement; if ((_ref = document.readystate) === "interactive" || _ref === "complete") { this.start(); } else { document.addeventlistener('domcontentloaded', this.start); } return this.finished = []; }; wow.prototype.start = function() { var box, _i, _len, _ref; this.stopped = false; this.boxes = (function() { var _i, _len, _ref, _results; _ref = this.element.getelementsbyclassname(this.config.boxclass); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; _results.push(box); } return _results; }).call(this); this.all = (function() { var _i, _len, _ref, _results; _ref = this.boxes; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; _results.push(box); } return _results; }).call(this); if (this.boxes.length) { if (this.disabled()) { this.resetstyle(); } else { _ref = this.boxes; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; this.applystyle(box, true); } window.addeventlistener('scroll', this.scrollhandler, false); window.addeventlistener('resize', this.scrollhandler, false); this.interval = setinterval(this.scrollcallback, 50); } } if (this.config.live) { return new mutationobserver((function(_this) { return function(records) { var node, record, _j, _len1, _results; _results = []; for (_j = 0, _len1 = records.length; _j < _len1; _j++) { record = records[_j]; _results.push((function() { var _k, _len2, _ref1, _results1; _ref1 = record.addednodes || []; _results1 = []; for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { node = _ref1[_k]; _results1.push(this.dosync(node)); } return _results1; }).call(_this)); } return _results; }; })(this)).observe(document.body, { childlist: true, subtree: true }); } }; wow.prototype.stop = function() { this.stopped = true; window.removeeventlistener('scroll', this.scrollhandler, false); window.removeeventlistener('resize', this.scrollhandler, false); if (this.interval != null) { return clearinterval(this.interval); } }; wow.prototype.sync = function(element) { if (mutationobserver.notsupported) { return this.dosync(this.element); } }; wow.prototype.dosync = function(element) { var box, _i, _len, _ref, _results; if (!this.stopped) { if (element == null) { element = this.element; } if (element.nodetype !== 1) { return; } element = element.parentnode || element; _ref = element.getelementsbyclassname(this.config.boxclass); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; if (__indexof.call(this.all, box) < 0) { this.applystyle(box, true); this.boxes.push(box); this.all.push(box); _results.push(this.scrolled = true); } else { _results.push(void 0); } } return _results; } }; wow.prototype.show = function(box) { this.applystyle(box); return box.classname = "" + box.classname + " " + this.config.animateclass; }; wow.prototype.applystyle = function(box, hidden) { var delay, duration, iteration; duration = box.getattribute('data-wow-duration'); delay = box.getattribute('data-wow-delay'); iteration = box.getattribute('data-wow-iteration'); return this.animate((function(_this) { return function() { return _this.customstyle(box, hidden, duration, delay, iteration); }; })(this)); }; wow.prototype.animate = (function() { if ('requestanimationframe' in window) { return function(callback) { return window.requestanimationframe(callback); }; } else { return function(callback) { return callback(); }; } })(); wow.prototype.resetstyle = function() { var box, _i, _len, _ref, _results; _ref = this.boxes; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; _results.push(box.setattribute('style', 'visibility: visible;')); } return _results; }; wow.prototype.customstyle = function(box, hidden, duration, delay, iteration) { if (hidden) { this.cacheanimationname(box); } box.style.visibility = hidden ? 'hidden' : 'visible'; if (duration) { this.vendorset(box.style, { animationduration: duration }); } if (delay) { this.vendorset(box.style, { animationdelay: delay }); } if (iteration) { this.vendorset(box.style, { animationiterationcount: iteration }); } this.vendorset(box.style, { animationname: hidden ? 'none' : this.cachedanimationname(box) }); return box; }; wow.prototype.vendors = ["moz", "webkit"]; wow.prototype.vendorset = function(elem, properties) { var name, value, vendor, _results; _results = []; for (name in properties) { value = properties[name]; elem["" + name] = value; _results.push((function() { var _i, _len, _ref, _results1; _ref = this.vendors; _results1 = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { vendor = _ref[_i]; _results1.push(elem["" + vendor + (name.charat(0).touppercase()) + (name.substr(1))] = value); } return _results1; }).call(this)); } return _results; }; wow.prototype.vendorcss = function(elem, property) { var result, style, vendor, _i, _len, _ref; style = window.getcomputedstyle(elem); result = style.getpropertycssvalue(property); _ref = this.vendors; for (_i = 0, _len = _ref.length; _i < _len; _i++) { vendor = _ref[_i]; result = result || style.getpropertycssvalue("-" + vendor + "-" + property); } return result; }; wow.prototype.animationname = function(box) { var animationname; try { animationname = this.vendorcss(box, 'animation-name').csstext; } catch (_error) { animationname = window.getcomputedstyle(box).getpropertyvalue('animation-name'); } if (animationname === 'none') { return ''; } else { return animationname; } }; wow.prototype.cacheanimationname = function(box) { return this.animationnamecache.set(box, this.animationname(box)); }; wow.prototype.cachedanimationname = function(box) { return this.animationnamecache.get(box); }; wow.prototype.scrollhandler = function() { return this.scrolled = true; }; wow.prototype.scrollcallback = function() { var box; if (this.scrolled) { this.scrolled = false; this.boxes = (function() { var _i, _len, _ref, _results; _ref = this.boxes; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { box = _ref[_i]; if (!(box)) { continue; } if (this.isvisible(box)) { this.show(box); continue; } _results.push(box); } return _results; }).call(this); if (!(this.boxes.length || this.config.live)) { return this.stop(); } } }; wow.prototype.offsettop = function(element) { var top; while (element.offsettop === void 0) { element = element.parentnode; } top = element.offsettop; while (element = element.offsetparent) { top += element.offsettop; } return top; }; wow.prototype.isvisible = function(box) { var bottom, offset, top, viewbottom, viewtop; offset = box.getattribute('data-wow-offset') || this.config.offset; viewtop = window.pageyoffset; viewbottom = viewtop + math.min(this.element.clientheight, innerheight) - offset; top = this.offsettop(box); bottom = top + box.clientheight; return top <= viewbottom && bottom >= viewtop; }; wow.prototype.util = function() { return this._util != null ? this._util : this._util = new util(); }; wow.prototype.disabled = function() { return !this.config.mobile && this.util().ismobile(navigator.useragent); }; return wow; })(); }).call(this);