1/*! 2 * jQuery Ticker Plugin v1.2.1 3 * https://github.com/BenjaminRH/jquery-ticker 4 * 5 * Copyright 2014 Benjamin Harris 6 * Released under the MIT license 7 */ 8 9'use strict'; 10 11var defaultOptions = { 12 // String: Selector to indicate each ticker item. Must be a direct child of the ticker element 13 item: 'div', 14 15 // Boolean: Toggles whether the ticker should pause if the mouse cursor is over it 16 pauseOnHover: false, 17 18 // Number: Speed of ticker in Pixels/Second. 19 speed: 60, 20 21 // String: (track|item) Sets whether ticker breaks when it hits a new item or if the track has reset 22 pauseAt: '', 23 24 // Number: Pause duration for pauseAt 25 delay: 500 26}; 27 28var rafSupported = true; 29 30// Check for Transform Support | Credit: https://stackoverflow.com/questions/7212102/detect-with-javascript-or-jquery-if-css-transform-2d-is-available 31function getSupportedTransform() { 32 var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); 33 var div = document.createElement('div'); 34 for (var i = 0; i < prefixes.length; i++) { 35 if (div && div.style[prefixes[i]] !== undefined) { 36 return prefixes[i]; 37 } 38 } 39 return false; 40} 41 42// Polyfill for requestAnimationFrame | Credit: https://stackoverflow.com/questions/5605588/how-to-use-requestanimationframe 43var requestAnimFrame = function () { 44 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function ( /* function */callback) { 45 rafSupported = false; 46 window.setTimeout(callback, 1000 / 60); 47 }; 48}(); 49 50function createCommonjsModule(fn, module) { 51 return module = { exports: {} }, fn(module, module.exports), module.exports; 52} 53 54/** 55 * Helpers. 56 */ 57 58var s = 1000; 59var m = s * 60; 60var h = m * 60; 61var d = h * 24; 62var y = d * 365.25; 63 64/** 65 * Parse or format the given `val`. 66 * 67 * Options: 68 * 69 * - `long` verbose formatting [false] 70 * 71 * @param {String|Number} val 72 * @param {Object} [options] 73 * @throws {Error} throw an error if val is not a non-empty string or a number 74 * @return {String|Number} 75 * @api public 76 */ 77 78var ms = function(val, options) { 79 options = options || {}; 80 var type = typeof val; 81 if (type === 'string' && val.length > 0) { 82 return parse(val); 83 } else if (type === 'number' && isNaN(val) === false) { 84 return options.long ? fmtLong(val) : fmtShort(val); 85 } 86 throw new Error( 87 'val is not a non-empty string or a valid number. val=' + 88 JSON.stringify(val) 89 ); 90}; 91 92/** 93 * Parse the given `str` and return milliseconds. 94 * 95 * @param {String} str 96 * @return {Number} 97 * @api private 98 */ 99 100function parse(str) { 101 str = String(str); 102 if (str.length > 100) { 103 return; 104 } 105 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( 106 str 107 ); 108 if (!match) { 109 return; 110 } 111 var n = parseFloat(match[1]); 112 var type = (match[2] || 'ms').toLowerCase(); 113 switch (type) { 114 case 'years': 115 case 'year': 116 case 'yrs': 117 case 'yr': 118 case 'y': 119 return n * y; 120 case 'days': 121 case 'day': 122 case 'd': 123 return n * d; 124 case 'hours': 125 case 'hour': 126 case 'hrs': 127 case 'hr': 128 case 'h': 129 return n * h; 130 case 'minutes': 131 case 'minute': 132 case 'mins': 133 case 'min': 134 case 'm': 135 return n * m; 136 case 'seconds': 137 case 'second': 138 case 'secs': 139 case 'sec': 140 case 's': 141 return n * s; 142 case 'milliseconds': 143 case 'millisecond': 144 case 'msecs': 145 case 'msec': 146 case 'ms': 147 return n; 148 default: 149 return undefined; 150 } 151} 152 153/** 154 * Short format for `ms`. 155 * 156 * @param {Number} ms 157 * @return {String} 158 * @api private 159 */ 160 161function fmtShort(ms) { 162 if (ms >= d) { 163 return Math.round(ms / d) + 'd'; 164 } 165 if (ms >= h) { 166 return Math.round(ms / h) + 'h'; 167 } 168 if (ms >= m) { 169 return Math.round(ms / m) + 'm'; 170 } 171 if (ms >= s) { 172 return Math.round(ms / s) + 's'; 173 } 174 return ms + 'ms'; 175} 176 177/** 178 * Long format for `ms`. 179 * 180 * @param {Number} ms 181 * @return {String} 182 * @api private 183 */ 184 185function fmtLong(ms) { 186 return plural(ms, d, 'day') || 187 plural(ms, h, 'hour') || 188 plural(ms, m, 'minute') || 189 plural(ms, s, 'second') || 190 ms + ' ms'; 191} 192
vendor: 4,817 bytes, lines 193-415
193/** 194 * Pluralization helper. 195 */ 196 197function plural(ms, n, name) { 198 if (ms < n) { 199 return; 200 } 201 if (ms < n * 1.5) { 202 return Math.floor(ms / n) + ' ' + name; 203 } 204 return Math.ceil(ms / n) + ' ' + name + 's'; 205} 206 207 208 209var ms$2 = Object.freeze({ 210 default: ms, 211 __moduleExports: ms 212}); 213 214var require$$0 = ( ms$2 && ms ) || ms$2; 215 216var debug = createCommonjsModule(function (module, exports) { 217/** 218 * This is the common logic for both the Node.js and web browser 219 * implementations of `debug()`. 220 * 221 * Expose `debug()` as the module. 222 */ 223 224exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; 225exports.coerce = coerce; 226exports.disable = disable; 227exports.enable = enable; 228exports.enabled = enabled; 229exports.humanize = require$$0; 230 231/** 232 * Active `debug` instances. 233 */ 234exports.instances = []; 235 236/** 237 * The currently active debug mode names, and names to skip. 238 */ 239 240exports.names = []; 241exports.skips = []; 242 243/** 244 * Map of special "%n" handling functions, for the debug "format" argument. 245 * 246 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". 247 */ 248 249exports.formatters = {}; 250 251/** 252 * Select a color. 253 * @param {String} namespace 254 * @return {Number} 255 * @api private 256 */ 257 258function selectColor(namespace) { 259 var hash = 0, i; 260 261 for (i in namespace) { 262 hash = ((hash << 5) - hash) + namespace.charCodeAt(i); 263 hash |= 0; // Convert to 32bit integer 264 } 265 266 return exports.colors[Math.abs(hash) % exports.colors.length]; 267} 268 269/** 270 * Create a debugger with the given `namespace`. 271 * 272 * @param {String} namespace 273 * @return {Function} 274 * @api public 275 */ 276 277function createDebug(namespace) { 278 279 var prevTime; 280 281 function debug() { 282 // disabled? 283 if (!debug.enabled) return; 284 285 var self = debug; 286 287 // set `diff` timestamp 288 var curr = +new Date(); 289 var ms = curr - (prevTime || curr); 290 self.diff = ms; 291 self.prev = prevTime; 292 self.curr = curr; 293 prevTime = curr; 294 295 // turn the `arguments` into a proper Array 296 var args = new Array(arguments.length); 297 for (var i = 0; i < args.length; i++) { 298 args[i] = arguments[i]; 299 } 300 301 args[0] = exports.coerce(args[0]); 302 303 if ('string' !== typeof args[0]) { 304 // anything else let's inspect with %O 305 args.unshift('%O'); 306 } 307 308 // apply any `formatters` transformations 309 var index = 0; 310 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { 311 // if we encounter an escaped % then don't increase the array index 312 if (match === '%%') return match; 313 index++; 314 var formatter = exports.formatters[format]; 315 if ('function' === typeof formatter) { 316 var val = args[index]; 317 match = formatter.call(self, val); 318 319 // now we need to remove `args[index]` since it's inlined in the `format` 320 args.splice(index, 1); 321 index--; 322 } 323 return match; 324 }); 325 326 // apply env-specific formatting (colors, etc.) 327 exports.formatArgs.call(self, args); 328 329 var logFn = debug.log || exports.log || console.log.bind(console); 330 logFn.apply(self, args); 331 } 332 333 debug.namespace = namespace; 334 debug.enabled = exports.enabled(namespace); 335 debug.useColors = exports.useColors(); 336 debug.color = selectColor(namespace); 337 debug.destroy = destroy; 338 339 // env-specific initialization logic for debug instances 340 if ('function' === typeof exports.init) { 341 exports.init(debug); 342 } 343 344 exports.instances.push(debug); 345 346 return debug; 347} 348 349function destroy () { 350 var index = exports.instances.indexOf(this); 351 if (index !== -1) { 352 exports.instances.splice(index, 1); 353 return true; 354 } else { 355 return false; 356 } 357} 358 359/** 360 * Enables a debug mode by namespaces. This can include modes 361 * separated by a colon and wildcards. 362 * 363 * @param {String} namespaces 364 * @api public 365 */ 366 367function enable(namespaces) { 368 exports.save(namespaces); 369 370 exports.names = []; 371 exports.skips = []; 372 373 var i; 374 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); 375 var len = split.length; 376 377 for (i = 0; i < len; i++) { 378 if (!split[i]) continue; // ignore empty strings 379 namespaces = split[i].replace(/\*/g, '.*?'); 380 if (namespaces[0] === '-') { 381 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); 382 } else { 383 exports.names.push(new RegExp('^' + namespaces + '$')); 384 } 385 } 386 387 for (i = 0; i < exports.instances.length; i++) { 388 var instance = exports.instances[i]; 389 instance.enabled = exports.enabled(instance.namespace); 390 } 391} 392 393/** 394 * Disable debug output. 395 * 396 * @api public 397 */ 398 399function disable() { 400 exports.enable(''); 401} 402 403/** 404 * Returns true if the given mode name is enabled, false otherwise. 405 * 406 * @param {String} name 407 * @return {Boolean} 408 * @api public 409 */ 410 411function enabled(name) { 412 if (name[name.length - 1] === '*') { 413 return true; 414 } 415 var i, len;
416 for (i = 0, len = exports.skips.length; i < len; i++) { 417 if (exports.skips[i].test(name)) { 418 return false; 419 } 420 } 421 for (i = 0, len = exports.names.length; i < len; i++) { 422 if (exports.names[i].test(name)) { 423 return true; 424 } 425 } 426 return false; 427} 428 429/** 430 * Coerce `val`. 431 * 432 * @param {Mixed} val 433 * @return {Mixed} 434 * @api private 435 */ 436 437function coerce(val) { 438 if (val instanceof Error) return val.stack || val.message; 439 return val; 440} 441}); 442 443var debug_1 = debug.coerce; 444var debug_2 = debug.disable; 445var debug_3 = debug.enable; 446var debug_4 = debug.enabled; 447var debug_5 = debug.humanize; 448var debug_6 = debug.instances; 449var debug_7 = debug.names; 450var debug_8 = debug.skips; 451var debug_9 = debug.formatters; 452 453 454var debug$2 = Object.freeze({ 455 default: debug, 456 __moduleExports: debug, 457 coerce: debug_1, 458 disable: debug_2, 459 enable: debug_3, 460 enabled: debug_4, 461 humanize: debug_5, 462 instances: debug_6, 463 names: debug_7, 464 skips: debug_8, 465 formatters: debug_9 466}); 467 468var require$$0$1 = ( debug$2 && debug ) || debug$2; 469 470var browser = createCommonjsModule(function (module, exports) { 471/** 472 * This is the web browser implementation of `debug()`. 473 * 474 * Expose `debug()` as the module. 475 */ 476 477exports = module.exports = require$$0$1; 478exports.log = log; 479exports.formatArgs = formatArgs; 480exports.save = save; 481exports.load = load; 482exports.useColors = useColors; 483exports.storage = 'undefined' != typeof chrome 484 && 'undefined' != typeof chrome.storage 485 ? chrome.storage.local 486 : localstorage(); 487 488/** 489 * Colors. 490 */ 491 492exports.colors = [ 493 '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', 494 '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', 495 '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', 496 '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', 497 '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', 498 '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
499 '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', 500 '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', 501 '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', 502 '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', 503 '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' 504]; 505 506/** 507 * Currently only WebKit-based Web Inspectors, Firefox >= v31, 508 * and the Firebug extension (any Firefox version) are known 509 * to support "%c" CSS customizations. 510 * 511 * TODO: add a `localStorage` variable to explicitly enable/disable colors 512 */ 513 514function useColors() { 515 // NB: In an Electron preload script, document will be defined but not fully 516 // initialized. Since we know we're in Chrome, we'll just detect this case 517 // explicitly 518 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { 519 return true; 520 } 521 522 // Internet Explorer and Edge do not support colors. 523 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { 524 return false; 525 } 526 527 // is webkit? http://stackoverflow.com/a/16459606/376773 528 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 529 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || 530 // is firebug? http://stackoverflow.com/a/398120/376773 531 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || 532 // is firefox >= v31? 533 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 534 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || 535 // double check webkit in userAgent just in case we are in a worker 536 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); 537} 538 539/** 540 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. 541 */ 542 543exports.formatters.j = function(v) { 544 try { 545 return JSON.stringify(v); 546 } catch (err) { 547 return '[UnexpectedJSONParseError]: ' + err.message; 548 } 549}; 550 551 552/** 553 * Colorize log arguments if enabled. 554 * 555 * @api public 556 */ 557 558function formatArgs(args) { 559 var useColors = this.useColors; 560 561 args[0] = (useColors ? '%c' : '') 562 + this.namespace 563 + (useColors ? ' %c' : ' ') 564 + args[0] 565 + (useColors ? '%c ' : ' ') 566 + '+' + exports.humanize(this.diff); 567 568 if (!useColors) return; 569 570 var c = 'color: ' + this.color; 571 args.splice(1, 0, c, 'color: inherit'); 572 573 // the final "%c" is somewhat tricky, because there could be other 574 // arguments passed either before or after the %c, so we need to 575 // figure out the correct index to insert the CSS into 576 var index = 0; 577 var lastC = 0; 578 args[0].replace(/%[a-zA-Z%]/g, function(match) { 579 if ('%%' === match) return; 580 index++; 581 if ('%c' === match) { 582 // we only are interested in the *last* %c 583 // (the user may have provided their own) 584 lastC = index; 585 } 586 }); 587 588 args.splice(lastC, 0, c); 589} 590 591/** 592 * Invokes `console.log()` when available. 593 * No-op when `console.log` is not a "function". 594 * 595 * @api public 596 */ 597 598function log() { 599 // this hackery is required for IE8/9, where 600 // the `console.log` function doesn't have 'apply' 601 return 'object' === typeof console 602 && console.log 603 && Function.prototype.apply.call(console.log, console, arguments); 604} 605 606/** 607 * Save `namespaces`. 608 * 609 * @param {String} namespaces 610 * @api private 611 */ 612 613function save(namespaces) { 614 try { 615 if (null == namespaces) { 616 exports.storage.removeItem('debug'); 617 } else { 618 exports.storage.debug = namespaces; 619 } 620 } catch(e) {} 621} 622 623/** 624 * Load `namespaces`. 625 * 626 * @return {String} returns the previously persisted debug modes 627 * @api private 628 */ 629 630function load() { 631 var r; 632 try { 633 r = exports.storage.debug; 634 } catch(e) {} 635 636 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG 637 if (!r && typeof process !== 'undefined' && 'env' in process) { 638 r = process.env.DEBUG; 639 } 640 641 return r; 642} 643 644/** 645 * Enable namespaces listed in `localStorage.debug` initially. 646 */ 647 648exports.enable(load()); 649 650/** 651 * Localstorage attempts to return the localstorage. 652 * 653 * This is necessary because safari throws 654 * when a user disables cookies/localstorage 655 * and you attempt to access it. 656 * 657 * @return {LocalStorage} 658 * @api private 659 */ 660 661function localstorage() { 662 try { 663 return window.localStorage; 664 } catch (e) {} 665} 666}); 667 668var browser_1 = browser.log; 669var browser_2 = browser.formatArgs; 670var browser_3 = browser.save; 671var browser_4 = browser.load; 672var browser_5 = browser.useColors; 673var browser_6 = browser.storage; 674var browser_7 = browser.colors; 675 676 677var browser$2 = Object.freeze({ 678 default: browser, 679 __moduleExports: browser, 680 log: browser_1, 681 formatArgs: browser_2, 682 save: browser_3, 683 load: browser_4, 684 useColors: browser_5, 685 storage: browser_6, 686 colors: browser_7 687}); 688 689var require$$0$2 = ( browser$2 && browser ) || browser$2; 690 691var logger = function logger(location) { 692 { 693 var debug = require$$0$2; 694 695 debug.enable('ticker:*'); 696 697 return debug('ticker:' + location); 698 } 699}; 700 701/* This is where the magic happens */ 702var log$1 = logger('brain'); 703 704var FPSs = [60]; 705 706var tickers = []; 707 708function getFps() { 709 //return 60; 710 if (!rafSupported) return 60; 711 var l = FPSs.length; 712 return FPSs.reduce(function (a, b) { 713 return a + b; 714 }) / l; 715} 716 717var brain = { 718 get fps() { 719 return getFps(); 720 }, 721 get tickers() { 722 return tickers; 723 }, 724 init: function init($) { 725 var frameCount = 0; 726 var fpsInterval = 0; 727
728 requestAnimFrame(function tick() { 729 frameCount++; 730 if (tickers.length) tickers.forEach(function (t) { 731 return t.advance(); 732 }); 733 734 requestAnimFrame(tick); 735 }); 736 737 // Monitor fps 738 if (rafSupported) { 739 var fpsMon = void 0; 740 $(window).on('load focus', function () { 741 log$1('Frame Count: %d, FPS Interval: %d', frameCount, fpsInterval); 742 if (!fpsMon && document.hasFocus()) { 743 fpsInterval = frameCount; 744 fpsMon = setInterval(function () { 745 var fps = frameCount - fpsInterval; 746 FPSs.push(fps); 747 748 while (FPSs.length > 10) { 749 FPSs.shift(); 750 }log$1(getFps()); 751 752 fpsInterval = frameCount; 753 }, 1000); 754 } 755 }).on('blur', function () { 756 clearInterval(fpsMon); 757 fpsMon = null; 758 }); 759 } 760 } 761}; 762 763var asyncGenerator = function () { 764 function AwaitValue(value) { 765 this.value = value; 766 } 767 768 function AsyncGenerator(gen) { 769 var front, back; 770 771 function send(key, arg) { 772 return new Promise(function (resolve, reject) { 773 var request = { 774 key: key, 775 arg: arg, 776 resolve: resolve, 777 reject: reject, 778 next: null 779 }; 780 781 if (back) { 782 back = back.next = request; 783 } else { 784 front = back = request; 785 resume(key, arg); 786 } 787 }); 788 } 789 790 function resume(key, arg) { 791 try { 792 var result = gen[key](arg); 793 var value = result.value; 794 795 if (value instanceof AwaitValue) { 796 Promise.resolve(value.value).then(function (arg) { 797 resume("next", arg); 798 }, function (arg) { 799 resume("throw", arg); 800 }); 801 } else { 802 settle(result.done ? "return" : "normal", result.value); 803 } 804 } catch (err) { 805 settle("throw", err); 806 } 807 } 808 809 function settle(type, value) { 810 switch (type) { 811 case "return": 812 front.resolve({ 813 value: value, 814 done: true 815 }); 816 break; 817 818 case "throw": 819 front.reject(value); 820 break; 821 822 default: 823 front.resolve({ 824 value: value, 825 done: false 826 }); 827 break; 828 } 829 830 front = front.next; 831 832 if (front) { 833 resume(front.key, front.arg); 834 } else { 835 back = null; 836 } 837 } 838 839 this._invoke = send; 840 841 if (typeof gen.return !== "function") { 842 this.return = undefined; 843 } 844 } 845 846 if (typeof Symbol === "function" && Symbol.asyncIterator) { 847 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 848 return this; 849 }; 850 } 851 852 AsyncGenerator.prototype.next = function (arg) { 853 return this._invoke("next", arg); 854 }; 855 856 AsyncGenerator.prototype.throw = function (arg) { 857 return this._invoke("throw", arg); 858 }; 859 860 AsyncGenerator.prototype.return = function (arg) { 861 return this._invoke("return", arg); 862 }; 863 864 return { 865 wrap: function (fn) { 866 return function () { 867 return new AsyncGenerator(fn.apply(this, arguments)); 868 }; 869 }, 870 await: function (value) { 871 return new AwaitValue(value); 872 } 873 }; 874}(); 875 876 877 878 879 880var classCallCheck = function (instance, Constructor) { 881 if (!(instance instanceof Constructor)) { 882 throw new TypeError("Cannot call a class as a function"); 883 } 884}; 885 886var createClass = function () { 887 function defineProperties(target, props) { 888 for (var i = 0; i < props.length; i++) { 889 var descriptor = props[i]; 890 descriptor.enumerable = descriptor.enumerable || false; 891 descriptor.configurable = true; 892 if ("value" in descriptor) descriptor.writable = true; 893 Object.defineProperty(target, descriptor.key, descriptor); 894 } 895 } 896 897 return function (Constructor, protoProps, staticProps) { 898 if (protoProps) defineProperties(Constructor.prototype, protoProps); 899 if (staticProps) defineProperties(Constructor, staticProps); 900 return Constructor; 901 }; 902}(); 903 904/* Ticker Class - Controls each instance of a ticker. */ 905 906var log$2 = logger('class'); 907 908/* TODO: Port over to private fields 909 * - Requires Gulp setup 910 **/ 911 912var Ticker = function () { 913 function Ticker(elem, settings) { 914 classCallCheck(this, Ticker); 915 916 this.elem = elem; 917 918 this.settings = settings; 919 920 this.__offset = 0; 921 this.__pauseTracker = 0; 922 923 this.build(); 924 } 925 926 createClass(Ticker, [{ 927 key: 'build', 928 value: function build() { 929 var _this = this; 930 931 if (!this.started) { 932 this.started = true; 933 934 //region Build Track 935 var track = document.createElement('div'); // <div class="js-ticker-track">; 936 track.className = 'js-ticker-track'; 937 938 this.elem.addClass('js-ticker'); 939 this.elem.children(this.settings.item).addClass('js-ticker-item').appendTo(track); 940 941 this.elem.append(track); 942 //endregion 943 944 //region Init Variables 945 this.track = this.elem.find('.js-ticker-track'); 946 this.__items = this.track.children('.js-ticker-item'); 947 948 this.__first = this.__items.first(); 949 this.__first.attr('data-first', true); 950 //endregion 951 952 //region Clone For Scale 953 var targetWidth = this.elem.width() + this.__first.width(); 954 955 log$2('(Pre Clones) Target Width: %d, Actual: %d', targetWidth, this.elem[0].scrollWidth); 956 957 while (this.elem[0].scrollWidth < targetWidth) { 958 this.__items.each(function (i) { 959 _this.track.append(_this.__items.eq(i).clone()); 960 }); 961 } 962 963 log$2('(Post Clones) Target Width: %d, Actual: %d', targetWidth, this.elem[0].scrollWidth); 964 //endregion 965 966 //region Init Events 967 // Insurance to prevent doubling up on enter triggers 968 /* FIXME: This looks... un... safe. */ 969 var initHover = function initHover() { 970 _this.elem.one('mouseenter', function () { 971 _this.__pauseTracker++; 972 _this.elem.one('mouseleave', function () { 973 _this.__pauseTracker--; 974 initHover(); 975 }); 976 }); 977 }; 978 979 if (this.settings.pauseOnHover) initHover(); 980 981 /* TODO: Pause on focus and reset slider position for ADA 982 * - Also need a solution on keyboard navigation 983 **/ 984 //endregion 985 986 //region Enable Ticker 987 this.elem.addClass('active'); 988 this.elem.data('ticker', this); 989 990 brain.tickers.push(this); 991 //endregion 992 } 993 } 994 }, { 995 key: 'advance', 996 value: function advance() { 997 var _this2 = this; 998 999 this.__width = this.__first.outerWidth(); 1000 if (!this.__pauseTracker) { 1001 1002 this.__offset += this.settings.speed / brain.fps; 1003 1004 /* TODO: Need a solution to go in reverse */ 1005 if (this.__offset > this.__width) { 1006 this.__offset = 0; 1007 this.__first.appendTo(this.track); 1008 this.__first = this.track.children('.js-ticker-item').first(); 1009 if (this.settings.pauseAt === 'item' || this.settings.pauseAt === 'track' && this.__first.data('first')) { 1010 this.__pauseTracker++; 1011 setTimeout(function () { 1012 return _this2.__pauseTracker--; 1013 }, this.settings.delay); 1014 } 1015 } 1016
1017 var transformProp = getSupportedTransform(); 1018 1019 if (transformProp) { 1020 this.track.css(transformProp, 'translateX(' + -this.__offset + 'px)'); 1021 } else { 1022 this.track.css('left', -this.__offset + 'px'); 1023 } 1024 } 1025 } 1026 }, { 1027 key: 'pause', 1028 value: function pause() { 1029 if (!this.__manuallyPaused) { 1030 this.__pauseTracker++; 1031 this.__manuallyPaused = true; 1032 } 1033 } 1034 }, { 1035 key: 'play', 1036 value: function play() { 1037 if (this.__manuallyPaused) { 1038 this.__pauseTracker--; 1039 this.__manuallyPaused = false; 1040 } 1041 } 1042 }, { 1043 key: 'toggle', 1044 value: function toggle() { 1045 if (this.__manuallyPaused) { 1046 this.play(); 1047 } else { 1048 this.pause(); 1049 } 1050 } 1051 }], [{ 1052 key: 'version', 1053 get: function get$$1() { 1054 return '0.0.1'; 1055 } 1056 }]); 1057 return Ticker; 1058}(); 1059 1060/** 1061 * Small jQuery Plugin create by Quangdao Nguyen 1062 */ 1063 1064var log = logger('entry'); 1065 1066(function ($) { 1067 'use strict'; 1068 1069 if (!$) return console.warn('Whoa there, buddy! Looks like you included the jQuery Ticker plugin without including jQuery first.'); 1070 1071 $.ticker = function (elem, settings) { 1072 return new Ticker($(elem), settings); 1073 }; 1074 1075 $.fn.ticker = function () { 1076 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 1077 1078 return this.each(function () { 1079 $.ticker(this, $.extend(true, {}, defaultOptions, overrides)); 1080 }); 1081 }; 1082 1083 brain.init($); 1084})(typeof jQuery !== 'undefined' ? jQuery : null);
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.