wow.min.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*! WOW - v1.0.1 - 2014-09-03
  2. * Copyright (c) 2014 Matthieu Aussaguel; Licensed MIT */
  3. (function() {
  4. var a, b, c, d, e, f = function(a, b) {
  5. return function() {
  6. return a.apply(b, arguments)
  7. }
  8. },
  9. g = [].indexOf || function(a) {
  10. for(var b = 0, c = this.length; c > b; b++)
  11. if(b in this && this[b] === a) return b;
  12. return -1
  13. };
  14. b = function() {
  15. function a() {}
  16. return a.prototype.extend = function(a, b) {
  17. var c, d;
  18. for(c in b) d = b[c], null == a[c] && (a[c] = d);
  19. return a
  20. }, a.prototype.isMobile = function(a) {
  21. return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(a)
  22. }, a.prototype.addEvent = function(a, b, c) {
  23. return null != a.addEventListener ? a.addEventListener(b, c, !1) : null != a.attachEvent ? a.attachEvent("on" + b, c) : a[b] = c
  24. }, a.prototype.removeEvent = function(a, b, c) {
  25. return null != a.removeEventListener ? a.removeEventListener(b, c, !1) : null != a.detachEvent ? a.detachEvent("on" + b, c) : delete a[b]
  26. }, a.prototype.innerHeight = function() {
  27. return "innerHeight" in window ? window.innerHeight : document.documentElement.clientHeight
  28. }, a
  29. }(), c = this.WeakMap || this.MozWeakMap || (c = function() {
  30. function a() {
  31. this.keys = [], this.values = []
  32. }
  33. return a.prototype.get = function(a) {
  34. var b, c, d, e, f;
  35. for(f = this.keys, b = d = 0, e = f.length; e > d; b = ++d)
  36. if(c = f[b], c === a) return this.values[b]
  37. }, a.prototype.set = function(a, b) {
  38. var c, d, e, f, g;
  39. for(g = this.keys, c = e = 0, f = g.length; f > e; c = ++e)
  40. if(d = g[c], d === a) return void(this.values[c] = b);
  41. return this.keys.push(a), this.values.push(b)
  42. }, a
  43. }()), a = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (a = function() {
  44. function a() {
  45. "undefined" != typeof console && null !== console && console.warn("MutationObserver is not supported by your browser."), "undefined" != typeof console && null !== console && console.warn("WOW.js cannot detect dom mutations, please call .sync() after loading new content.")
  46. }
  47. return a.notSupported = !0, a.prototype.observe = function() {}, a
  48. }()), d = this.getComputedStyle || function(a) {
  49. return this.getPropertyValue = function(b) {
  50. var c;
  51. return "float" === b && (b = "styleFloat"), e.test(b) && b.replace(e, function(a, b) {
  52. return b.toUpperCase()
  53. }), (null != (c = a.currentStyle) ? c[b] : void 0) || null
  54. }, this
  55. }, e = /(\-([a-z]){1})/g, this.WOW = function() {
  56. function e(a) {
  57. null == a && (a = {}), this.scrollCallback = f(this.scrollCallback, this), this.scrollHandler = f(this.scrollHandler, this), this.start = f(this.start, this), this.scrolled = !0, this.config = this.util().extend(a, this.defaults), this.animationNameCache = new c
  58. }
  59. return e.prototype.defaults = {
  60. boxClass: "wow",
  61. animateClass: "animated",
  62. offset: 0,
  63. mobile: !0,
  64. live: !0
  65. }, e.prototype.init = function() {
  66. var a;
  67. return this.element = window.document.documentElement, "interactive" === (a = document.readyState) || "complete" === a ? this.start() : this.util().addEvent(document, "DOMContentLoaded", this.start), this.finished = []
  68. }, e.prototype.start = function() {
  69. var b, c, d, e;
  70. if(this.stopped = !1, this.boxes = function() {
  71. var a, c, d, e;
  72. for(d = this.element.querySelectorAll("." + this.config.boxClass), e = [], a = 0, c = d.length; c > a; a++) b = d[a], e.push(b);
  73. return e
  74. }.call(this), this.all = function() {
  75. var a, c, d, e;
  76. for(d = this.boxes, e = [], a = 0, c = d.length; c > a; a++) b = d[a], e.push(b);
  77. return e
  78. }.call(this), this.boxes.length)
  79. if(this.disabled()) this.resetStyle();
  80. else {
  81. for(e = this.boxes, c = 0, d = e.length; d > c; c++) b = e[c], this.applyStyle(b, !0);
  82. this.util().addEvent(window, "scroll", this.scrollHandler), this.util().addEvent(window, "resize", this.scrollHandler), this.interval = setInterval(this.scrollCallback, 50)
  83. }
  84. return this.config.live ? new a(function(a) {
  85. return function(b) {
  86. var c, d, e, f, g;
  87. for(g = [], e = 0, f = b.length; f > e; e++) d = b[e], g.push(function() {
  88. var a, b, e, f;
  89. for(e = d.addedNodes || [], f = [], a = 0, b = e.length; b > a; a++) c = e[a], f.push(this.doSync(c));
  90. return f
  91. }.call(a));
  92. return g
  93. }
  94. }(this)).observe(document.body, {
  95. childList: !0,
  96. subtree: !0
  97. }) : void 0
  98. }, e.prototype.stop = function() {
  99. return this.stopped = !0, this.util().removeEvent(window, "scroll", this.scrollHandler), this.util().removeEvent(window, "resize", this.scrollHandler), null != this.interval ? clearInterval(this.interval) : void 0
  100. }, e.prototype.sync = function() {
  101. return a.notSupported ? this.doSync(this.element) : void 0
  102. }, e.prototype.doSync = function(a) {
  103. var b, c, d, e, f;
  104. if(!this.stopped) {
  105. if(null == a && (a = this.element), 1 !== a.nodeType) return;
  106. for(a = a.parentNode || a, e = a.querySelectorAll("." + this.config.boxClass), f = [], c = 0, d = e.length; d > c; c++) b = e[c], g.call(this.all, b) < 0 ? (this.applyStyle(b, !0), this.boxes.push(b), this.all.push(b), f.push(this.scrolled = !0)) : f.push(void 0);
  107. return f
  108. }
  109. }, e.prototype.show = function(a) {
  110. return this.applyStyle(a), a.className = "" + a.className + " " + this.config.animateClass
  111. }, e.prototype.applyStyle = function(a, b) {
  112. var c, d, e;
  113. return d = a.getAttribute("data-wow-duration"), c = a.getAttribute("data-wow-delay"), e = a.getAttribute("data-wow-iteration"), this.animate(function(f) {
  114. return function() {
  115. return f.customStyle(a, b, d, c, e)
  116. }
  117. }(this))
  118. }, e.prototype.animate = function() {
  119. return "requestAnimationFrame" in window ? function(a) {
  120. return window.requestAnimationFrame(a)
  121. } : function(a) {
  122. return a()
  123. }
  124. }(), e.prototype.resetStyle = function() {
  125. var a, b, c, d, e;
  126. for(d = this.boxes, e = [], b = 0, c = d.length; c > b; b++) a = d[b], e.push(a.setAttribute("style", "visibility: visible;"));
  127. return e
  128. }, e.prototype.customStyle = function(a, b, c, d, e) {
  129. return b && this.cacheAnimationName(a), a.style.visibility = b ? "hidden" : "visible", c && this.vendorSet(a.style, {
  130. animationDuration: c
  131. }), d && this.vendorSet(a.style, {
  132. animationDelay: d
  133. }), e && this.vendorSet(a.style, {
  134. animationIterationCount: e
  135. }), this.vendorSet(a.style, {
  136. animationName: b ? "none" : this.cachedAnimationName(a)
  137. }), a
  138. }, e.prototype.vendors = ["moz", "webkit"], e.prototype.vendorSet = function(a, b) {
  139. var c, d, e, f;
  140. f = [];
  141. for(c in b) d = b[c], a["" + c] = d, f.push(function() {
  142. var b, f, g, h;
  143. for(g = this.vendors, h = [], b = 0, f = g.length; f > b; b++) e = g[b], h.push(a["" + e + c.charAt(0).toUpperCase() + c.substr(1)] = d);
  144. return h
  145. }.call(this));
  146. return f
  147. }, e.prototype.vendorCSS = function(a, b) {
  148. var c, e, f, g, h, i;
  149. for(e = d(a), c = e.getPropertyCSSValue(b), i = this.vendors, g = 0, h = i.length; h > g; g++) f = i[g], c = c || e.getPropertyCSSValue("-" + f + "-" + b);
  150. return c
  151. }, e.prototype.animationName = function(a) {
  152. var b;
  153. try {
  154. b = this.vendorCSS(a, "animation-name").cssText
  155. } catch(c) {
  156. b = d(a).getPropertyValue("animation-name")
  157. }
  158. return "none" === b ? "" : b
  159. }, e.prototype.cacheAnimationName = function(a) {
  160. return this.animationNameCache.set(a, this.animationName(a))
  161. }, e.prototype.cachedAnimationName = function(a) {
  162. return this.animationNameCache.get(a)
  163. }, e.prototype.scrollHandler = function() {
  164. return this.scrolled = !0
  165. }, e.prototype.scrollCallback = function() {
  166. var a;
  167. return !this.scrolled || (this.scrolled = !1, this.boxes = function() {
  168. var b, c, d, e;
  169. for(d = this.boxes, e = [], b = 0, c = d.length; c > b; b++) a = d[b], a && (this.isVisible(a) ? this.show(a) : e.push(a));
  170. return e
  171. }.call(this), this.boxes.length || this.config.live) ? void 0 : this.stop()
  172. }, e.prototype.offsetTop = function(a) {
  173. for(var b; void 0 === a.offsetTop;) a = a.parentNode;
  174. for(b = a.offsetTop; a = a.offsetParent;) b += a.offsetTop;
  175. return b
  176. }, e.prototype.isVisible = function(a) {
  177. var b, c, d, e, f;
  178. return c = a.getAttribute("data-wow-offset") || this.config.offset, f = window.pageYOffset, e = f + Math.min(this.element.clientHeight, this.util().innerHeight()) - c, d = this.offsetTop(a), b = d + a.clientHeight, e >= d && b >= f
  179. }, e.prototype.util = function() {
  180. return null != this._util ? this._util : this._util = new b
  181. }, e.prototype.disabled = function() {
  182. return !this.config.mobile && this.util().isMobile(navigator.userAgent)
  183. }, e
  184. }()
  185. }).call(this);