/** * @license WOW wow.js - v1.3.0 - 2016-10-04 https://wowjs.uk Copyright (c) 2016 Thomas Grainger; Licensed MIT */ 'use strict'; !function(context, factory) { if ("function" == typeof define && define.amd) { define(["module", "exports"], factory); } else { if ("undefined" != typeof exports) { factory(module, exports); } else { var module = { exports : {} }; factory(module, module.exports); context.WOW = module.exports; } } }(this, function(module, exports) { /** * @param {!AudioNode} b * @param {!Function} a * @return {undefined} */ function debug(b, a) { if (!(b instanceof a)) { throw new TypeError("Cannot call a class as a function"); } } /** * @param {string} name * @param {!Array} res * @return {?} */ function callback(name, res) { return res.indexOf(name) >= 0; } /** * @param {!Object} a * @param {!Object} b * @return {?} */ function merge(a, b) { var prop; for (prop in b) { if (null == a[prop]) { var h = b[prop]; a[prop] = h; } } return a; } /** * @param {string} sample * @return {?} */ function detect(sample) { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(sample); } /** * @param {string} type * @return {?} */ function fireEvent(type) { var b = arguments.length <= 1 || void 0 === arguments[1] ? false : arguments[1]; var c = arguments.length <= 2 || void 0 === arguments[2] ? false : arguments[2]; var eDetail = arguments.length <= 3 || void 0 === arguments[3] ? null : arguments[3]; var e = void 0; return null != document.createEvent ? (e = document.createEvent("CustomEvent"), e.initCustomEvent(type, b, c, eDetail)) : null != document.createEventObject ? (e = document.createEventObject(), e.eventType = type) : e.eventName = type, e; } /** * @param {!Object} elem * @param {string} type * @return {undefined} */ function trigger(elem, type) { if (null != elem.dispatchEvent) { elem.dispatchEvent(type); } else { if (type in (null != elem)) { elem[type](); } else { if ("on" + type in (null != elem)) { elem["on" + type](); } } } } /** * @param {!Object} elem * @param {string} event * @param {?} listener * @return {undefined} */ function listen(elem, event, listener) { if (null != elem.addEventListener) { elem.addEventListener(event, listener, false); } else { if (null != elem.attachEvent) { elem.attachEvent("on" + event, listener); } else { elem[event] = listener; } } } /** * @param {!Object} elem * @param {string} type * @param {?} fn * @return {undefined} */ function removeEvent(elem, type, fn) { if (null != elem.removeEventListener) { elem.removeEventListener(type, fn, false); } else { if (null != elem.detachEvent) { elem.detachEvent("on" + type, fn); } else { delete elem[type]; } } } /** * @return {?} */ function fn() { return "innerHeight" in window ? window.innerHeight : document.documentElement.clientHeight; } Object.defineProperty(exports, "__esModule", { value : true }); var costSum; var gasSum; var j = function() { /** * @param {!Function} target * @param {string} props * @return {undefined} */ function defineProperties(target, props) { /** @type {number} */ var i = 0; for (; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; /** @type {boolean} */ descriptor.configurable = true; if ("value" in descriptor) { /** @type {boolean} */ descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function(Constructor, protoProps, staticProps) { return protoProps && defineProperties(Constructor.prototype, protoProps), staticProps && defineProperties(Constructor, staticProps), Constructor; }; }(); var WeakMap = window.WeakMap || window.MozWeakMap || function() { /** * @return {undefined} */ function n() { debug(this, n); /** @type {!Array} */ this.keys = []; /** @type {!Array} */ this.values = []; } return j(n, [{ key : "get", value : function(a) { /** @type {number} */ var i = 0; for (; i < this.keys.length; i++) { var key = this.keys[i]; if (key === a) { return this.values[i]; } } } }, { key : "set", value : function(a, b) { /** @type {number} */ var i = 0; for (; i < this.keys.length; i++) { var key = this.keys[i]; if (key === a) { return this.values[i] = b, this; } } return this.keys.push(a), this.values.push(b), this; } }]), n; }(); var MutationObserver = window.MutationObserver || window.WebkitMutationObserver || window.MozMutationObserver || (gasSum = costSum = function() { /** * @return {undefined} */ function n() { debug(this, n); if ("undefined" != typeof console && null !== console) { console.warn("MutationObserver is not supported by your browser."); console.warn("WOW.js cannot detect dom mutations, please call .sync() after loading new content."); } } return j(n, [{ key : "observe", value : function() { } }]), n; }(), costSum.notSupported = true, gasSum); var getComputedStyle = window.getComputedStyle || function(elem) { /** @type {!RegExp} */ var b = /(\-([a-z]){1})/g; return { getPropertyValue : function(property) { if ("float" === property) { /** @type {string} */ property = "styleFloat"; } if (b.test(property)) { property.replace(b, function(a, shortMonthName) { return shortMonthName.toUpperCase(); }); } var currentStyle = elem.currentStyle; return (null != currentStyle ? currentStyle[property] : void 0) || null; } }; }; var LinkCreate = function() { /** * @return {undefined} */ function f() { var params = arguments.length <= 0 || void 0 === arguments[0] ? {} : arguments[0]; debug(this, f); this.defaults = { boxClass : "wow", animateClass : "animated", offset : 0, mobile : true, live : true, callback : null, scrollContainer : null, resetAnimation : true }; this.animate = function() { return "requestAnimationFrame" in window ? function(checkCount) { return window.requestAnimationFrame(checkCount); } : function(saveNotifs) { return saveNotifs(); }; }(); /** @type {!Array} */ this.vendors = ["moz", "webkit"]; this.start = this.start.bind(this); this.resetAnimation = this.resetAnimation.bind(this); this.scrollHandler = this.scrollHandler.bind(this); this.scrollCallback = this.scrollCallback.bind(this); /** @type {boolean} */ this.scrolled = true; this.config = merge(params, this.defaults); if (null != params.scrollContainer) { /** @type {(Element|null)} */ this.config.scrollContainer = document.querySelector(params.scrollContainer); } this.animationNameCache = new WeakMap; this.wowEvent = fireEvent(this.config.boxClass); } return j(f, [{ key : "init", value : function() { this.element = window.document.documentElement; if (callback(document.readyState, ["interactive", "complete"])) { this.start(); } else { listen(document, "DOMContentLoaded", this.start); } /** @type {!Array} */ this.finished = []; } }, { key : "start", value : function() { var exports = this; if (this.stopped = false, this.boxes = [].slice.call(this.element.querySelectorAll("." + this.config.boxClass)), this.all = this.boxes.slice(0), this.boxes.length) { if (this.disabled()) { this.resetStyle(); } else { /** @type {number} */ var i = 0; for (; i < this.boxes.length; i++) { var box = this.boxes[i]; this.applyStyle(box, true); } } } if (this.disabled() || (listen(this.config.scrollContainer || window, "scroll", this.scrollHandler), listen(window, "resize", this.scrollHandler), this.interval = setInterval(this.scrollCallback, 50)), this.config.live) { var observer = new MutationObserver(function(blocksToFetch) { /** @type {number} */ var bi = 0; for (; bi < blocksToFetch.length; bi++) { var block = blocksToFetch[bi]; /** @type {number} */ var i = 0; for (; i < block.addedNodes.length; i++) { var ret = block.addedNodes[i]; exports.doSync(ret); } } }); observer.observe(document.body, { childList : true, subtree : true }); } } }, { key : "stop", value : function() { /** @type {boolean} */ this.stopped = true; removeEvent(this.config.scrollContainer || window, "scroll", this.scrollHandler); removeEvent(window, "resize", this.scrollHandler); if (null != this.interval) { clearInterval(this.interval); } } }, { key : "sync", value : function() { if (MutationObserver.notSupported) { this.doSync(this.element); } } }, { key : "doSync", value : function(elem) { if ("undefined" != typeof elem && null !== elem || (elem = this.element), 1 === elem.nodeType) { elem = elem.parentNode || elem; var checkBoxes = elem.querySelectorAll("." + this.config.boxClass); /** @type {number} */ var i = 0; for (; i < checkBoxes.length; i++) { var box = checkBoxes[i]; if (!callback(box, this.all)) { this.boxes.push(box); this.all.push(box); if (this.stopped || this.disabled()) { this.resetStyle(); } else { this.applyStyle(box, true); } /** @type {boolean} */ this.scrolled = true; } } } } }, { key : "show", value : function(element) { return this.applyStyle(element), element.className = element.className + " " + this.config.animateClass, null != this.config.callback && this.config.callback(element), trigger(element, this.wowEvent), this.config.resetAnimation && (listen(element, "animationend", this.resetAnimation), listen(element, "oanimationend", this.resetAnimation), listen(element, "webkitAnimationEnd", this.resetAnimation), listen(element, "MSAnimationEnd", this.resetAnimation)), element; } }, { key : "applyStyle", value : function(box, hidden) { var _this = this; var duration = box.getAttribute("data-wow-duration"); var delay = box.getAttribute("data-wow-delay"); var iteration = box.getAttribute("data-wow-iteration"); return this.animate(function() { return _this.customStyle(box, hidden, duration, delay, iteration); }); } }, { key : "resetStyle", value : function() { /** @type {number} */ var i = 0; for (; i < this.boxes.length; i++) { var b = this.boxes[i]; /** @type {string} */ b.style.visibility = "visible"; } } }, { key : "resetAnimation", value : function(event) { if (event.type.toLowerCase().indexOf("animationend") >= 0) { var recordVideo = event.target || event.srcElement; recordVideo.className = recordVideo.className.replace(this.config.animateClass, "").trim(); } } }, { key : "customStyle", value : function(box, hidden, duration, delay, iteration) { return hidden && this.cacheAnimationName(box), box.style.visibility = hidden ? "hidden" : "visible", duration && this.vendorSet(box.style, { animationDuration : duration }), delay && this.vendorSet(box.style, { animationDelay : delay }), iteration && this.vendorSet(box.style, { animationIterationCount : iteration }), this.vendorSet(box.style, { animationName : hidden ? "none" : this.cachedAnimationName(box) }), box; } }, { key : "vendorSet", value : function(a, b) { var n; for (n in b) { if (b.hasOwnProperty(n)) { var v = b[n]; a["" + n] = v; /** @type {number} */ var i = 0; for (; i < this.vendors.length; i++) { var f = this.vendors[i]; a["" + f + n.charAt(0).toUpperCase() + n.substr(1)] = v; } } } } }, { key : "vendorCSS", value : function(elem, attr) { var compStyle = getComputedStyle(elem); var changed = compStyle.getPropertyCSSValue(attr); /** @type {number} */ var i = 0; for (; i < this.vendors.length; i++) { var f = this.vendors[i]; changed = changed || compStyle.getPropertyCSSValue("-" + f + "-" + attr); } return changed; } }, { key : "animationName", value : function(box) { var val = void 0; try { val = this.vendorCSS(box, "animation-name").cssText; } catch (c) { val = getComputedStyle(box).getPropertyValue("animation-name"); } return "none" === val ? "" : val; } }, { key : "cacheAnimationName", value : function(box) { return this.animationNameCache.set(box, this.animationName(box)); } }, { key : "cachedAnimationName", value : function(leafId) { return this.animationNameCache.get(leafId); } }, { key : "scrollHandler", value : function() { /** @type {boolean} */ this.scrolled = true; } }, { key : "scrollCallback", value : function() { if (this.scrolled) { /** @type {boolean} */ this.scrolled = false; /** @type {!Array} */ var stackables = []; /** @type {number} */ var i = 0; for (; i < this.boxes.length; i++) { var box = this.boxes[i]; if (box) { if (this.isVisible(box)) { this.show(box); continue; } stackables.push(box); } } /** @type {!Array} */ this.boxes = stackables; if (!(this.boxes.length || this.config.live)) { this.stop(); } } } }, { key : "offsetTop", value : function(elem) { for (; void 0 === elem.offsetTop;) { elem = elem.parentNode; } var result = elem.offsetTop; for (; elem.offsetParent;) { elem = elem.offsetParent; result = result + elem.offsetTop; } return result; } }, { key : "isVisible", value : function(box) { var pv = box.getAttribute("data-wow-offset") || this.config.offset; var osy = this.config.scrollContainer && this.config.scrollContainer.scrollTop || window.pageYOffset; /** @type {number} */ var py = osy + Math.min(this.element.clientHeight, fn()) - pv; var y = this.offsetTop(box); var ty = y + box.clientHeight; return py >= y && ty >= osy; } }, { key : "disabled", value : function() { return !this.config.mobile && detect(navigator.userAgent); } }]), f; }(); exports["default"] = LinkCreate; module.exports = exports["default"]; });