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