vendor: 16,943 bytes, lines 1-538
1(function (global, factory) { 2 if (typeof define === "function" && define.amd) { 3 define(['module', 'exports'], factory); 4 } else if (typeof exports !== "undefined") { 5 factory(module, exports); 6 } else { 7 var mod = { 8 exports: {} 9 }; 10 factory(mod, mod.exports); 11 global.WOW = mod.exports; 12 } 13})(this, function (module, exports) { 14 'use strict'; 15 16 Object.defineProperty(exports, "__esModule", { 17 value: true 18 }); 19 20 var _class, _temp; 21 22 function _classCallCheck(instance, Constructor) { 23 if (!(instance instanceof Constructor)) { 24 throw new TypeError("Cannot call a class as a function"); 25 } 26 } 27 28 var _createClass = function () { 29 function defineProperties(target, props) { 30 for (var i = 0; i < props.length; i++) { 31 var descriptor = props[i]; 32 descriptor.enumerable = descriptor.enumerable || false; 33 descriptor.configurable = true; 34 if ("value" in descriptor) descriptor.writable = true; 35 Object.defineProperty(target, descriptor.key, descriptor); 36 } 37 } 38 39 return function (Constructor, protoProps, staticProps) { 40 if (protoProps) defineProperties(Constructor.prototype, protoProps); 41 if (staticProps) defineProperties(Constructor, staticProps); 42 return Constructor; 43 }; 44 }(); 45 46 function isIn(needle, haystack) { 47 return haystack.indexOf(needle) >= 0; 48 } 49 50 function extend(custom, defaults) { 51 for (var key in defaults) { 52 if (custom[key] == null) { 53 var value = defaults[key]; 54 custom[key] = value; 55 } 56 } 57 return custom; 58 } 59 60 function isMobile(agent) { 61 return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent) 62 ); 63 } 64 65 function createEvent(event) { 66 var bubble = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; 67 var cancel = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; 68 var detail = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; 69 70 var customEvent = void 0; 71 if (document.createEvent != null) { 72 // W3C DOM 73 customEvent = document.createEvent('CustomEvent'); 74 customEvent.initCustomEvent(event, bubble, cancel, detail); 75 } else if (document.createEventObject != null) { 76 // IE DOM < 9 77 customEvent = document.createEventObject(); 78 customEvent.eventType = event; 79 } else { 80 customEvent.eventName = event; 81 } 82 83 return customEvent; 84 } 85 86 function emitEvent(elem, event) { 87 if (elem.dispatchEvent != null) { 88 // W3C DOM 89 elem.dispatchEvent(event); 90 } else if (event in (elem != null)) { 91 elem[event](); 92 } else if ('on' + event in (elem != null)) { 93 elem['on' + event](); 94 } 95 } 96 97 function addEvent(elem, event, fn) { 98 if (elem.addEventListener != null) { 99 // W3C DOM 100 elem.addEventListener(event, fn, false); 101 } else if (elem.attachEvent != null) { 102 // IE DOM 103 elem.attachEvent('on' + event, fn); 104 } else { 105 // fallback 106 elem[event] = fn; 107 } 108 } 109 110 function removeEvent(elem, event, fn) { 111 if (elem.removeEventListener != null) { 112 // W3C DOM 113 elem.removeEventListener(event, fn, false); 114 } else if (elem.detachEvent != null) { 115 // IE DOM 116 elem.detachEvent('on' + event, fn); 117 } else { 118 // fallback 119 delete elem[event]; 120 } 121 } 122 123 function getInnerHeight() { 124 if ('innerHeight' in window) { 125 return window.innerHeight; 126 } 127 128 return document.documentElement.clientHeight; 129 } 130 131 // Minimalistic WeakMap shim, just in case. 132 var WeakMap = window.WeakMap || window.MozWeakMap || function () { 133 function WeakMap() { 134 _classCallCheck(this, WeakMap); 135 136 this.keys = []; 137 this.values = []; 138 } 139 140 _createClass(WeakMap, [{ 141 key: 'get', 142 value: function get(key) { 143 for (var i = 0; i < this.keys.length; i++) { 144 var item = this.keys[i]; 145 if (item === key) { 146 return this.values[i]; 147 } 148 } 149 return undefined; 150 } 151 }, { 152 key: 'set', 153 value: function set(key, value) { 154 for (var i = 0; i < this.keys.length; i++) { 155 var item = this.keys[i]; 156 if (item === key) { 157 this.values[i] = value; 158 return this; 159 } 160 } 161 this.keys.push(key); 162 this.values.push(value); 163 return this; 164 } 165 }]); 166 167 return WeakMap; 168 }(); 169 170 // Dummy MutationObserver, to avoid raising exceptions. 171 var MutationObserver = window.MutationObserver || window.WebkitMutationObserver || window.MozMutationObserver || (_temp = _class = function () { 172 function MutationObserver() { 173 _classCallCheck(this, MutationObserver); 174 175 if (typeof console !== 'undefined' && console !== null) { 176 console.warn('MutationObserver is not supported by your browser.'); 177 console.warn('WOW.js cannot detect dom mutations, please call .sync() after loading new content.'); 178 } 179 } 180 181 _createClass(MutationObserver, [{ 182 key: 'observe', 183 value: function observe() {} 184 }]); 185 186 return MutationObserver; 187 }(), _class.notSupported = true, _temp); 188 189 // getComputedStyle shim, from http://stackoverflow.com/a/21797294 190 var getComputedStyle = window.getComputedStyle || function getComputedStyle(el) { 191 var getComputedStyleRX = /(\-([a-z]){1})/g; 192 return { 193 getPropertyValue: function getPropertyValue(prop) { 194 if (prop === 'float') { 195 prop = 'styleFloat'; 196 } 197 if (getComputedStyleRX.test(prop)) { 198 prop.replace(getComputedStyleRX, function (_, _char) { 199 return _char.toUpperCase(); 200 }); 201 } 202 var currentStyle = el.currentStyle; 203 204 return (currentStyle != null ? currentStyle[prop] : void 0) || null; 205 } 206 }; 207 }; 208 209 var WOW = function () { 210 function WOW() { 211 212 var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; 213 214 _classCallCheck(this, WOW); 215 216 this.defaults = { 217 boxClass: 'wow', 218 animateClass: 'animated', 219 offset: 0, 220 mobile: true, 221 live: true, 222 callback: null, 223 scrollContainer: null, 224 resetAnimation: true 225 }; 226 227 this.animate = function animateFactory() { 228 if ('requestAnimationFrame' in window) { 229 return function (callback) { 230 return window.requestAnimationFrame(callback); 231 }; 232 } 233 return function (callback) { 234 return callback(); 235 }; 236 }(); 237 238 this.vendors = ['moz', 'webkit']; 239 240 this.start = this.start.bind(this); 241 this.resetAnimation = this.resetAnimation.bind(this); 242 this.scrollHandler = this.scrollHandler.bind(this); 243 this.scrollCallback = this.scrollCallback.bind(this); 244 this.scrolled = true; 245 this.config = extend(options, this.defaults); 246 if (options.scrollContainer != null) { 247 this.config.scrollContainer = document.querySelector(options.scrollContainer); 248 } 249 // Map of elements to animation names: 250 this.animationNameCache = new WeakMap(); 251 this.wowEvent = createEvent(this.config.boxClass); 252 } 253 254 _createClass(WOW, [{ 255 key: 'init', 256 value: function init() { 257 258 this.element = window.document.documentElement; 259 if (isIn(document.readyState, ['interactive', 'complete'])) { 260 this.start(); 261 } else { 262 addEvent(document, 'DOMContentLoaded', this.start); 263 } 264 this.finished = []; 265 } 266 }, { 267 key: 'start', 268 value: function start() { 269 var _this = this; 270 271 this.stopped = false; 272 this.boxes = [].slice.call(this.element.querySelectorAll('.' + this.config.boxClass)); 273 this.all = this.boxes.slice(0); 274 if (this.boxes.length) { 275 if (this.disabled()) { 276 this.resetStyle(); 277 } else { 278 for (var i = 0; i < this.boxes.length; i++) { 279 var box = this.boxes[i]; 280 this.applyStyle(box, true); 281 } 282 } 283 } 284 if (!this.disabled()) { 285 addEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler); 286 addEvent(window, 'resize', this.scrollHandler); 287 this.interval = setInterval(this.scrollCallback, 50); 288 } 289 if (this.config.live) { 290 var mut = new MutationObserver(function (records) { 291 for (var j = 0; j < records.length; j++) { 292 var record = records[j]; 293 for (var k = 0; k < record.addedNodes.length; k++) { 294 var node = record.addedNodes[k]; 295 _this.doSync(node); 296 } 297 } 298 return undefined; 299 }); 300 mut.observe(document.body, { 301 childList: true, 302 subtree: true 303 }); 304 } 305 } 306 }, { 307 key: 'stop', 308 value: function stop() { 309 this.stopped = true; 310 removeEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler); 311 removeEvent(window, 'resize', this.scrollHandler); 312 if (this.interval != null) { 313 clearInterval(this.interval); 314 } 315 } 316 }, { 317 key: 'sync', 318 value: function sync() { 319 if (MutationObserver.notSupported) { 320 this.doSync(this.element); 321 } 322 } 323 }, { 324 key: 'doSync', 325 value: function doSync(element) { 326 if (typeof element === 'undefined' || element === null) { 327 element = this.element; 328 } 329 if (element.nodeType !== 1) { 330 return; 331 } 332 element = element.parentNode || element; 333 var iterable = element.querySelectorAll('.' + this.config.boxClass); 334 for (var i = 0; i < iterable.length; i++) { 335 var box = iterable[i]; 336 if (!isIn(box, this.all)) { 337 this.boxes.push(box); 338 this.all.push(box); 339 if (this.stopped || this.disabled()) { 340 this.resetStyle(); 341 } else { 342 this.applyStyle(box, true); 343 } 344 this.scrolled = true; 345 } 346 } 347 } 348 }, { 349 key: 'show', 350 value: function show(box) { 351 this.applyStyle(box); 352 box.className = box.className + ' ' + this.config.animateClass; 353 if (this.config.callback != null) { 354 this.config.callback(box); 355 } 356 emitEvent(box, this.wowEvent); 357 358 if (this.config.resetAnimation) { 359 addEvent(box, 'animationend', this.resetAnimation); 360 addEvent(box, 'oanimationend', this.resetAnimation); 361 addEvent(box, 'webkitAnimationEnd', this.resetAnimation); 362 addEvent(box, 'MSAnimationEnd', this.resetAnimation); 363 } 364 365 return box; 366 } 367 }, { 368 key: 'applyStyle', 369 value: function applyStyle(box, hidden) { 370 var _this2 = this; 371 372 var duration = box.getAttribute('data-wow-duration'); 373 var delay = box.getAttribute('data-wow-delay'); 374 var iteration = box.getAttribute('data-wow-iteration'); 375 376 return this.animate(function () { 377 return _this2.customStyle(box, hidden, duration, delay, iteration); 378 }); 379 } 380 }, { 381 key: 'resetStyle', 382 value: function resetStyle() { 383 for (var i = 0; i < this.boxes.length; i++) { 384 var box = this.boxes[i]; 385 box.style.visibility = 'visible'; 386 } 387 return undefined; 388 } 389 }, { 390 key: 'resetAnimation', 391 value: function resetAnimation(event) { 392 if (event.type.toLowerCase().indexOf('animationend') >= 0) { 393 var target = event.target || event.srcElement; 394 target.className = target.className.replace(this.config.animateClass, '').trim(); 395 } 396 } 397 }, { 398 key: 'customStyle', 399 value: function customStyle(box, hidden, duration, delay, iteration) { 400 if (hidden) { 401 this.cacheAnimationName(box); 402 } 403 box.style.visibility = hidden ? 'hidden' : 'visible'; 404 405 if (duration) { 406 this.vendorSet(box.style, { animationDuration: duration }); 407 } 408 if (delay) { 409 this.vendorSet(box.style, { animationDelay: delay }); 410 } 411 if (iteration) { 412 this.vendorSet(box.style, { animationIterationCount: iteration }); 413 } 414 this.vendorSet(box.style, { animationName: hidden ? 'none' : this.cachedAnimationName(box) }); 415 416 return box; 417 } 418 }, { 419 key: 'vendorSet', 420 value: function vendorSet(elem, properties) { 421 for (var name in properties) { 422 if (properties.hasOwnProperty(name)) { 423 var value = properties[name]; 424 elem['' + name] = value; 425 for (var i = 0; i < this.vendors.length; i++) { 426 var vendor = this.vendors[i]; 427 elem['' + vendor + name.charAt(0).toUpperCase() + name.substr(1)] = value; 428 } 429 } 430 } 431 } 432 }, { 433 key: 'vendorCSS', 434 value: function vendorCSS(elem, property) { 435 var style = getComputedStyle(elem); 436 var result = style.getPropertyCSSValue(property); 437 for (var i = 0; i < this.vendors.length; i++) { 438 var vendor = this.vendors[i]; 439 result = result || style.getPropertyCSSValue('-' + vendor + '-' + property); 440 } 441 return result; 442 } 443 }, { 444 key: 'animationName', 445 value: function animationName(box) { 446 var aName = void 0; 447 try { 448 aName = this.vendorCSS(box, 'animation-name').cssText; 449 } catch (error) { 450 // Opera, fall back to plain property value 451 aName = getComputedStyle(box).getPropertyValue('animation-name'); 452 } 453 454 if (aName === 'none') { 455 return ''; // SVG/Firefox, unable to get animation name? 456 } 457 458 return aName; 459 } 460 }, { 461 key: 'cacheAnimationName', 462 value: function cacheAnimationName(box) { 463 // https://bugzilla.mozilla.org/show_bug.cgi?id=921834 464 // box.dataset is not supported for SVG elements in Firefox 465 return this.animationNameCache.set(box, this.animationName(box)); 466 } 467 }, { 468 key: 'cachedAnimationName', 469 value: function cachedAnimationName(box) { 470 return this.animationNameCache.get(box); 471 } 472 }, { 473 key: 'scrollHandler', 474 value: function scrollHandler() { 475 this.scrolled = true; 476 } 477 }, { 478 key: 'scrollCallback', 479 value: function scrollCallback() { 480 if (this.scrolled) { 481 this.scrolled = false; 482 var results = []; 483 for (var i = 0; i < this.boxes.length; i++) { 484 var box = this.boxes[i]; 485 if (box) { 486 if (this.isVisible(box)) { 487 this.show(box); 488 continue; 489 } 490 results.push(box); 491 } 492 } 493 this.boxes = results; 494 if (!this.boxes.length && !this.config.live) { 495 this.stop(); 496 } 497 } 498 } 499 }, { 500 key: 'offsetTop', 501 value: function offsetTop(element) { 502 // SVG elements don't have an offsetTop in Firefox. 503 // This will use their nearest parent that has an offsetTop. 504 // Also, using ('offsetTop' of element) causes an exception in Firefox. 505 while (element.offsetTop === undefined) { 506 element = element.parentNode; 507 } 508 var top = element.offsetTop; 509 while (element.offsetParent) { 510 element = element.offsetParent; 511 top += element.offsetTop; 512 } 513 return top; 514 } 515 }, { 516 key: 'isVisible', 517 value: function isVisible(box) { 518 var offset = box.getAttribute('data-wow-offset') || this.config.offset; 519 var viewTop = this.config.scrollContainer && this.config.scrollContainer.scrollTop || window.pageYOffset; 520 var viewBottom = viewTop + Math.min(this.element.clientHeight, getInnerHeight()) - offset; 521 var top = this.offsetTop(box); 522 var bottom = top + box.clientHeight; 523 524 return top <= viewBottom && bottom >= viewTop; 525 } 526 }, { 527 key: 'disabled', 528 value: function disabled() { 529 return !this.config.mobile && isMobile(navigator.userAgent); 530 } 531 }]); 532 533 return WOW; 534 }(); 535 536 exports.default = WOW; 537 module.exports = exports['default']; 538});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.