1'use strict'; 2 3 4 5var defaultOptions = { 6 7 // String: Selector to indicate each ticker item. Must be a direct child of the ticker element 8 9 item: 'div', 10 11 12 13 // Boolean: Toggles whether the ticker should pause if the mouse cursor is over it 14 15 pauseOnHover: false, 16 17 18 19 // Number: Speed of ticker in Pixels/Second. 20 21 speed: 60, 22 23 24 25 // String: (track|item) Sets whether ticker breaks when it hits a new item or if the track has reset 26 27 pauseAt: '', 28 29 30 31 // Number: Pause duration for pauseAt 32 33 delay: 500 34 35}; 36 37 38 39var rafSupported = true; 40 41 42 43// Check for Transform Support | Credit: https://stackoverflow.com/questions/7212102/detect-with-javascript-or-jquery-if-css-transform-2d-is-available 44 45function getSupportedTransform() { 46 47 var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); 48 49 var div = document.createElement('div'); 50 51 for (var i = 0; i < prefixes.length; i++) { 52 53 if (div && div.style[prefixes[i]] !== undefined) { 54 55 return prefixes[i]; 56 57 } 58 59 } 60 61 return false; 62 63} 64 65 66 67// Polyfill for requestAnimationFrame | Credit: https://stackoverflow.com/questions/5605588/how-to-use-requestanimationframe 68 69var requestAnimFrame = function () { 70 71 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function ( /* function */callback) { 72 73 rafSupported = false; 74 75 window.setTimeout(callback, 1000 / 60); 76 77 }; 78 79}(); 80 81 82 83function createCommonjsModule(fn, module) { 84 85 return module = { exports: {} }, fn(module, module.exports), module.exports; 86 87} 88 89 90 91/** 92 93 * Helpers. 94 95 */ 96 97 98 99var s = 1000; 100 101var m = s * 60; 102 103var h = m * 60; 104 105var d = h * 24; 106 107var y = d * 365.25; 108 109 110 111/** 112 113 * Parse or format the given `val`. 114 115 * 116 117 * Options: 118 119 * 120 121 * - `long` verbose formatting [false] 122 123 * 124 125 * @param {String|Number} val 126 127 * @param {Object} [options] 128 129 * @throws {Error} throw an error if val is not a non-empty string or a number 130 131 * @return {String|Number} 132 133 * @api public 134 135 */ 136 137 138 139var ms = function(val, options) { 140 141 options = options || {}; 142 143 var type = typeof val; 144 145 if (type === 'string' && val.length > 0) { 146 147 return parse(val); 148 149 } else if (type === 'number' && isNaN(val) === false) { 150 151 return options.long ? fmtLong(val) : fmtShort(val); 152 153 } 154 155 throw new Error( 156 157 'val is not a non-empty string or a valid number. val=' + 158 159 JSON.stringify(val) 160 161 ); 162 163}; 164 165 166 167/** 168 169 * Parse the given `str` and return milliseconds. 170 171 * 172 173 * @param {String} str 174 175 * @return {Number} 176 177 * @api private 178 179 */ 180 181 182 183function parse(str) { 184 185 str = String(str); 186 187 if (str.length > 100) { 188 189 return; 190 191 } 192 193 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( 194 195 str 196 197 ); 198 199 if (!match) { 200 201 return; 202 203 } 204 205 var n = parseFloat(match[1]); 206 207 var type = (match[2] || 'ms').toLowerCase(); 208 209 switch (type) { 210 211 case 'years': 212 213 case 'year': 214 215 case 'yrs': 216 217 case 'yr': 218 219 case 'y': 220 221 return n * y; 222 223 case 'days': 224 225 case 'day': 226 227 case 'd': 228 229 return n * d; 230 231 case 'hours': 232 233 case 'hour': 234 235 case 'hrs': 236 237 case 'hr': 238 239 case 'h': 240 241 return n * h; 242 243 case 'minutes': 244 245 case 'minute': 246 247 case 'mins': 248 249 case 'min': 250 251 case 'm': 252 253 return n * m; 254 255 case 'seconds': 256 257 case 'second': 258 259 case 'secs': 260 261 case 'sec': 262 263 case 's': 264 265 return n * s; 266 267 case 'milliseconds': 268 269 case 'millisecond': 270 271 case 'msecs': 272 273 case 'msec': 274 275 case 'ms': 276 277 return n; 278 279 default: 280 281 return undefined; 282 283 } 284 285} 286 287 288 289/** 290 291 * Short format for `ms`. 292 293 * 294 295 * @param {Number} ms 296 297 * @return {String} 298 299 * @api private 300 301 */ 302 303 304 305function fmtShort(ms) { 306 307 if (ms >= d) { 308 309 return Math.round(ms / d) + 'd'; 310 311 } 312 313 if (ms >= h) { 314 315 return Math.round(ms / h) + 'h'; 316 317 } 318 319 if (ms >= m) { 320 321 return Math.round(ms / m) + 'm'; 322 323 } 324 325 if (ms >= s) { 326 327 return Math.round(ms / s) + 's'; 328 329 } 330 331 return ms + 'ms'; 332 333} 334 335 336 337/** 338 339 * Long format for `ms`. 340 341 * 342 343 * @param {Number} ms 344 345 * @return {String} 346 347 * @api private 348 349 */ 350 351 352 353function fmtLong(ms) { 354 355 return plural(ms, d, 'day') || 356 357 plural(ms, h, 'hour') || 358 359 plural(ms, m, 'minute') || 360 361 plural(ms, s, 'second') || 362 363 ms + ' ms'; 364 365} 366 367 368 369/** 370 371 * Pluralization helper. 372 373 */ 374 375 376 377function plural(ms, n, name) { 378 379 if (ms < n) { 380 381 return; 382 383 } 384 385 if (ms < n * 1.5) { 386 387 return Math.floor(ms / n) + ' ' + name; 388 389 } 390 391 return Math.ceil(ms / n) + ' ' + name + 's'; 392 393} 394 395 396 397 398 399 400 401var ms$2 = Object.freeze({ 402 403 default: ms, 404 405 __moduleExports: ms 406 407}); 408 409 410 411var require$$0 = ( ms$2 && ms ) || ms$2; 412 413 414
415var debug = createCommonjsModule(function (module, exports) { 416 417/** 418 419 * This is the common logic for both the Node.js and web browser 420 421 * implementations of `debug()`. 422 423 * 424 425 * Expose `debug()` as the module. 426 427 */ 428 429 430 431exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; 432 433exports.coerce = coerce; 434 435exports.disable = disable; 436 437exports.enable = enable; 438 439exports.enabled = enabled; 440 441exports.humanize = require$$0; 442 443 444 445/** 446 447 * Active `debug` instances. 448 449 */ 450 451exports.instances = []; 452 453 454 455/** 456 457 * The currently active debug mode names, and names to skip. 458 459 */ 460 461 462 463exports.names = []; 464 465exports.skips = []; 466 467 468 469/** 470 471 * Map of special "%n" handling functions, for the debug "format" argument. 472 473 * 474 475 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". 476 477 */ 478 479 480 481exports.formatters = {}; 482 483 484 485/** 486 487 * Select a color. 488 489 * @param {String} namespace 490 491 * @return {Number} 492 493 * @api private 494 495 */ 496 497 498 499function selectColor(namespace) { 500 501 var hash = 0, i; 502 503 504 505 for (i in namespace) { 506 507 hash = ((hash << 5) - hash) + namespace.charCodeAt(i); 508 509 hash |= 0; // Convert to 32bit integer 510 511 } 512 513 514 515 return exports.colors[Math.abs(hash) % exports.colors.length]; 516 517} 518 519 520 521/** 522 523 * Create a debugger with the given `namespace`. 524 525 * 526 527 * @param {String} namespace 528 529 * @return {Function} 530 531 * @api public 532 533 */ 534 535 536 537function createDebug(namespace) { 538 539 540 541 var prevTime; 542 543 544 545 function debug() { 546 547 // disabled? 548 549 if (!debug.enabled) return; 550 551 552 553 var self = debug; 554 555 556 557 // set `diff` timestamp 558 559 var curr = +new Date(); 560 561 var ms = curr - (prevTime || curr); 562 563 self.diff = ms; 564 565 self.prev = prevTime; 566 567 self.curr = curr; 568 569 prevTime = curr; 570 571 572 573 // turn the `arguments` into a proper Array 574 575 var args = new Array(arguments.length); 576 577 for (var i = 0; i < args.length; i++) { 578 579 args[i] = arguments[i]; 580 581 } 582 583 584 585 args[0] = exports.coerce(args[0]); 586 587 588 589 if ('string' !== typeof args[0]) { 590 591 // anything else let's inspect with %O 592 593 args.unshift('%O'); 594 595 } 596 597 598 599 // apply any `formatters` transformations 600 601 var index = 0; 602 603 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { 604 605 // if we encounter an escaped % then don't increase the array index 606 607 if (match === '%%') return match; 608 609 index++; 610 611 var formatter = exports.formatters[format]; 612 613 if ('function' === typeof formatter) { 614 615 var val = args[index]; 616 617 match = formatter.call(self, val); 618 619 620 621 // now we need to remove `args[index]` since it's inlined in the `format` 622 623 args.splice(index, 1); 624 625 index--; 626 627 } 628 629 return match; 630 631 }); 632 633 634 635 // apply env-specific formatting (colors, etc.) 636 637 exports.formatArgs.call(self, args); 638 639 640 641 var logFn = debug.log || exports.log || console.log.bind(console); 642 643 logFn.apply(self, args); 644 645 } 646 647 648 649 debug.namespace = namespace; 650 651 debug.enabled = exports.enabled(namespace); 652 653 debug.useColors = exports.useColors(); 654 655 debug.color = selectColor(namespace); 656 657 debug.destroy = destroy; 658 659 660 661 // env-specific initialization logic for debug instances 662 663 if ('function' === typeof exports.init) { 664 665 exports.init(debug); 666 667 } 668 669 670 671 exports.instances.push(debug); 672 673 674 675 return debug; 676 677} 678 679 680 681function destroy () { 682 683 var index = exports.instances.indexOf(this); 684 685 if (index !== -1) { 686 687 exports.instances.splice(index, 1); 688 689 return true; 690 691 } else { 692 693 return false; 694 695 } 696 697} 698 699 700 701/** 702 703 * Enables a debug mode by namespaces. This can include modes 704 705 * separated by a colon and wildcards. 706 707 * 708 709 * @param {String} namespaces 710 711 * @api public 712 713 */ 714 715 716 717function enable(namespaces) { 718 719 exports.save(namespaces); 720 721 722 723 exports.names = []; 724 725 exports.skips = []; 726 727 728 729 var i; 730 731 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); 732 733 var len = split.length; 734 735 736 737 for (i = 0; i < len; i++) { 738 739 if (!split[i]) continue; // ignore empty strings 740 741 namespaces = split[i].replace(/\*/g, '.*?'); 742 743 if (namespaces[0] === '-') { 744 745 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); 746 747 } else { 748 749 exports.names.push(new RegExp('^' + namespaces + '$')); 750 751 } 752 753 } 754 755 756 757 for (i = 0; i < exports.instances.length; i++) { 758 759 var instance = exports.instances[i]; 760 761 instance.enabled = exports.enabled(instance.namespace); 762 763 } 764 765} 766 767 768 769/** 770 771 * Disable debug output. 772 773 * 774 775 * @api public 776 777 */ 778 779 780 781function disable() { 782 783 exports.enable(''); 784 785} 786 787 788 789/** 790 791 * Returns true if the given mode name is enabled, false otherwise. 792 793 * 794 795 * @param {String} name 796 797 * @return {Boolean} 798 799 * @api public 800 801 */ 802 803 804 805function enabled(name) { 806 807 if (name[name.length - 1] === '*') { 808 809 return true; 810 811 } 812 813 var i, len; 814
815 for (i = 0, len = exports.skips.length; i < len; i++) { 816 817 if (exports.skips[i].test(name)) { 818 819 return false; 820 821 } 822 823 } 824 825 for (i = 0, len = exports.names.length; i < len; i++) { 826 827 if (exports.names[i].test(name)) { 828 829 return true; 830 831 } 832 833 } 834 835 return false; 836 837} 838 839 840 841/** 842 843 * Coerce `val`. 844 845 * 846 847 * @param {Mixed} val 848 849 * @return {Mixed} 850 851 * @api private 852 853 */ 854 855 856 857function coerce(val) { 858 859 if (val instanceof Error) return val.stack || val.message; 860 861 return val; 862 863} 864 865}); 866 867 868 869var debug_1 = debug.coerce; 870 871var debug_2 = debug.disable; 872 873var debug_3 = debug.enable; 874 875var debug_4 = debug.enabled; 876 877var debug_5 = debug.humanize; 878 879var debug_6 = debug.instances; 880 881var debug_7 = debug.names; 882 883var debug_8 = debug.skips; 884 885var debug_9 = debug.formatters; 886 887 888 889 890 891var debug$2 = Object.freeze({ 892 893 default: debug, 894 895 __moduleExports: debug, 896 897 coerce: debug_1, 898 899 disable: debug_2, 900 901 enable: debug_3, 902 903 enabled: debug_4, 904 905 humanize: debug_5, 906 907 instances: debug_6, 908 909 names: debug_7, 910 911 skips: debug_8, 912 913 formatters: debug_9 914 915}); 916 917 918 919var require$$0$1 = ( debug$2 && debug ) || debug$2; 920 921 922 923var browser = createCommonjsModule(function (module, exports) { 924 925/** 926 927 * This is the web browser implementation of `debug()`. 928 929 * 930 931 * Expose `debug()` as the module. 932 933 */ 934 935 936 937exports = module.exports = require$$0$1; 938 939exports.log = log; 940 941exports.formatArgs = formatArgs; 942 943exports.save = save; 944 945exports.load = load; 946 947exports.useColors = useColors; 948 949exports.storage = 'undefined' != typeof chrome 950 951 && 'undefined' != typeof chrome.storage 952 953 ? chrome.storage.local 954 955 : localstorage(); 956 957 958 959/** 960 961 * Colors. 962 963 */ 964 965 966 967exports.colors = [ 968 969 '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', 970 971 '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', 972 973 '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', 974 975 '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', 976 977 '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', 978 979 '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', 980
981 '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', 982 983 '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', 984 985 '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', 986 987 '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', 988 989 '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' 990 991]; 992 993 994 995/** 996 997 * Currently only WebKit-based Web Inspectors, Firefox >= v31, 998 999 * and the Firebug extension (any Firefox version) are known 1000 1001 * to support "%c" CSS customizations. 1002 1003 * 1004 1005 * TODO: add a `localStorage` variable to explicitly enable/disable colors 1006 1007 */ 1008 1009 1010 1011function useColors() { 1012 1013 // NB: In an Electron preload script, document will be defined but not fully 1014 1015 // initialized. Since we know we're in Chrome, we'll just detect this case 1016 1017 // explicitly 1018 1019 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { 1020 1021 return true; 1022 1023 } 1024 1025 1026 1027 // Internet Explorer and Edge do not support colors. 1028 1029 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { 1030 1031 return false; 1032 1033 } 1034 1035 1036 1037 // is webkit? http://stackoverflow.com/a/16459606/376773 1038 1039 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 1040 1041 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || 1042 1043 // is firebug? http://stackoverflow.com/a/398120/376773 1044 1045 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || 1046 1047 // is firefox >= v31? 1048 1049 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 1050 1051 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || 1052 1053 // double check webkit in userAgent just in case we are in a worker 1054 1055 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); 1056 1057} 1058 1059 1060 1061/** 1062 1063 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. 1064 1065 */ 1066 1067 1068 1069exports.formatters.j = function(v) { 1070 1071 try { 1072 1073 return JSON.stringify(v); 1074 1075 } catch (err) { 1076 1077 return '[UnexpectedJSONParseError]: ' + err.message; 1078 1079 } 1080 1081}; 1082 1083 1084 1085 1086 1087/** 1088 1089 * Colorize log arguments if enabled. 1090 1091 * 1092 1093 * @api public 1094 1095 */ 1096 1097 1098 1099function formatArgs(args) { 1100 1101 var useColors = this.useColors; 1102 1103 1104 1105 args[0] = (useColors ? '%c' : '') 1106 1107 + this.namespace 1108 1109 + (useColors ? ' %c' : ' ') 1110 1111 + args[0] 1112 1113 + (useColors ? '%c ' : ' ') 1114 1115 + '+' + exports.humanize(this.diff); 1116 1117 1118 1119 if (!useColors) return; 1120 1121 1122 1123 var c = 'color: ' + this.color; 1124 1125 args.splice(1, 0, c, 'color: inherit'); 1126 1127 1128 1129 // the final "%c" is somewhat tricky, because there could be other 1130 1131 // arguments passed either before or after the %c, so we need to 1132 1133 // figure out the correct index to insert the CSS into 1134 1135 var index = 0; 1136 1137 var lastC = 0; 1138 1139 args[0].replace(/%[a-zA-Z%]/g, function(match) { 1140 1141 if ('%%' === match) return; 1142 1143 index++; 1144 1145 if ('%c' === match) { 1146 1147 // we only are interested in the *last* %c 1148 1149 // (the user may have provided their own) 1150 1151 lastC = index; 1152 1153 } 1154 1155 }); 1156 1157 1158 1159 args.splice(lastC, 0, c); 1160 1161} 1162 1163 1164 1165/** 1166 1167 * Invokes `console.log()` when available. 1168 1169 * No-op when `console.log` is not a "function". 1170 1171 * 1172 1173 * @api public 1174 1175 */ 1176 1177 1178 1179function log() { 1180 1181 // this hackery is required for IE8/9, where 1182 1183 // the `console.log` function doesn't have 'apply' 1184 1185 return 'object' === typeof console 1186 1187 && console.log 1188 1189 && Function.prototype.apply.call(console.log, console, arguments); 1190 1191} 1192 1193 1194 1195/** 1196 1197 * Save `namespaces`. 1198 1199 * 1200 1201 * @param {String} namespaces 1202 1203 * @api private 1204 1205 */ 1206 1207 1208 1209function save(namespaces) { 1210 1211 try { 1212 1213 if (null == namespaces) { 1214 1215 exports.storage.removeItem('debug'); 1216 1217 } else { 1218 1219 exports.storage.debug = namespaces; 1220 1221 } 1222 1223 } catch(e) {} 1224 1225} 1226 1227 1228 1229/** 1230 1231 * Load `namespaces`. 1232 1233 * 1234 1235 * @return {String} returns the previously persisted debug modes 1236 1237 * @api private 1238 1239 */ 1240 1241 1242 1243function load() { 1244 1245 var r; 1246 1247 try { 1248 1249 r = exports.storage.debug; 1250 1251 } catch(e) {} 1252 1253 1254 1255 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG 1256 1257 if (!r && typeof process !== 'undefined' && 'env' in process) { 1258 1259 r = process.env.DEBUG; 1260 1261 } 1262 1263 1264 1265 return r; 1266 1267} 1268 1269 1270 1271/** 1272 1273 * Enable namespaces listed in `localStorage.debug` initially. 1274 1275 */ 1276 1277 1278 1279exports.enable(load()); 1280 1281 1282 1283/** 1284 1285 * Localstorage attempts to return the localstorage. 1286 1287 * 1288 1289 * This is necessary because safari throws 1290 1291 * when a user disables cookies/localstorage 1292 1293 * and you attempt to access it. 1294 1295 * 1296 1297 * @return {LocalStorage} 1298 1299 * @api private 1300 1301 */ 1302 1303 1304 1305function localstorage() { 1306 1307 try { 1308 1309 return window.localStorage; 1310 1311 } catch (e) {} 1312 1313} 1314 1315}); 1316 1317 1318 1319var browser_1 = browser.log; 1320 1321var browser_2 = browser.formatArgs; 1322 1323var browser_3 = browser.save; 1324 1325var browser_4 = browser.load; 1326 1327var browser_5 = browser.useColors; 1328 1329var browser_6 = browser.storage; 1330 1331var browser_7 = browser.colors; 1332 1333 1334 1335 1336 1337var browser$2 = Object.freeze({ 1338 1339 default: browser, 1340 1341 __moduleExports: browser, 1342 1343 log: browser_1, 1344 1345 formatArgs: browser_2, 1346 1347 save: browser_3, 1348 1349 load: browser_4, 1350 1351 useColors: browser_5, 1352 1353 storage: browser_6, 1354 1355 colors: browser_7 1356 1357}); 1358 1359 1360 1361var require$$0$2 = ( browser$2 && browser ) || browser$2; 1362 1363 1364 1365var logger = function logger(location) { 1366 1367 { 1368 1369 var debug = require$$0$2; 1370 1371 1372 1373 debug.enable('ticker:*'); 1374 1375 1376 1377 return debug('ticker:' + location); 1378 1379 } 1380 1381}; 1382 1383 1384 1385/* This is where the magic happens */ 1386 1387var log$1 = logger('brain'); 1388 1389 1390 1391var FPSs = [60]; 1392 1393 1394 1395var tickers = []; 1396 1397 1398 1399function getFps() { 1400 1401 //return 60; 1402 1403 if (!rafSupported) return 60; 1404 1405 var l = FPSs.length; 1406 1407 return FPSs.reduce(function (a, b) { 1408 1409 return a + b; 1410 1411 }) / l; 1412 1413} 1414 1415 1416 1417var brain = { 1418 1419 get fps() { 1420 1421 return getFps(); 1422 1423 }, 1424 1425 get tickers() { 1426 1427 return tickers; 1428 1429 }, 1430 1431 init: function init($) { 1432 1433 var frameCount = 0; 1434 1435 var fpsInterval = 0; 1436 1437 1438
1439 requestAnimFrame(function tick() { 1440 1441 frameCount++; 1442 1443 if (tickers.length) tickers.forEach(function (t) { 1444 1445 return t.advance(); 1446 1447 }); 1448 1449 1450 1451 requestAnimFrame(tick); 1452 1453 }); 1454 1455 1456 1457 // Monitor fps 1458 1459 if (rafSupported) { 1460 1461 var fpsMon = void 0; 1462 1463 $(window).on('load focus', function () { 1464 1465 log$1('Frame Count: %d, FPS Interval: %d', frameCount, fpsInterval); 1466 1467 if (!fpsMon && document.hasFocus()) { 1468 1469 fpsInterval = frameCount; 1470 1471 fpsMon = setInterval(function () { 1472 1473 var fps = frameCount - fpsInterval; 1474 1475 FPSs.push(fps); 1476 1477 1478 1479 while (FPSs.length > 10) { 1480 1481 FPSs.shift(); 1482 1483 }log$1(getFps()); 1484 1485 1486 1487 fpsInterval = frameCount; 1488 1489 }, 1000); 1490 1491 } 1492 1493 }).on('blur', function () { 1494 1495 clearInterval(fpsMon); 1496 1497 fpsMon = null; 1498 1499 }); 1500 1501 } 1502 1503 } 1504 1505}; 1506 1507 1508 1509var asyncGenerator = function () { 1510 1511 function AwaitValue(value) { 1512 1513 this.value = value; 1514 1515 } 1516 1517 1518 1519 function AsyncGenerator(gen) { 1520 1521 var front, back; 1522 1523 1524 1525 function send(key, arg) { 1526 1527 return new Promise(function (resolve, reject) { 1528 1529 var request = { 1530 1531 key: key, 1532 1533 arg: arg, 1534 1535 resolve: resolve, 1536 1537 reject: reject, 1538 1539 next: null 1540 1541 }; 1542 1543 1544 1545 if (back) { 1546 1547 back = back.next = request; 1548 1549 } else { 1550 1551 front = back = request; 1552 1553 resume(key, arg); 1554 1555 } 1556 1557 }); 1558 1559 } 1560 1561 1562 1563 function resume(key, arg) { 1564 1565 try { 1566 1567 var result = gen[key](arg); 1568 1569 var value = result.value; 1570 1571 1572 1573 if (value instanceof AwaitValue) { 1574 1575 Promise.resolve(value.value).then(function (arg) { 1576 1577 resume("next", arg); 1578 1579 }, function (arg) { 1580 1581 resume("throw", arg); 1582 1583 }); 1584 1585 } else { 1586 1587 settle(result.done ? "return" : "normal", result.value); 1588 1589 } 1590 1591 } catch (err) { 1592 1593 settle("throw", err); 1594 1595 } 1596 1597 } 1598 1599 1600 1601 function settle(type, value) { 1602 1603 switch (type) { 1604 1605 case "return": 1606 1607 front.resolve({ 1608 1609 value: value, 1610 1611 done: true 1612 1613 }); 1614 1615 break; 1616 1617 1618 1619 case "throw": 1620 1621 front.reject(value); 1622 1623 break; 1624 1625 1626 1627 default: 1628 1629 front.resolve({ 1630 1631 value: value, 1632 1633 done: false 1634 1635 }); 1636 1637 break; 1638 1639 } 1640 1641 1642 1643 front = front.next; 1644 1645 1646 1647 if (front) { 1648 1649 resume(front.key, front.arg); 1650 1651 } else { 1652 1653 back = null; 1654 1655 } 1656 1657 } 1658 1659 1660 1661 this._invoke = send; 1662 1663 1664 1665 if (typeof gen.return !== "function") { 1666 1667 this.return = undefined; 1668 1669 } 1670 1671 } 1672 1673 1674 1675 if (typeof Symbol === "function" && Symbol.asyncIterator) { 1676 1677 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 1678 1679 return this; 1680 1681 }; 1682 1683 } 1684 1685 1686 1687 AsyncGenerator.prototype.next = function (arg) { 1688 1689 return this._invoke("next", arg); 1690 1691 }; 1692 1693 1694 1695 AsyncGenerator.prototype.throw = function (arg) { 1696 1697 return this._invoke("throw", arg); 1698 1699 }; 1700 1701 1702 1703 AsyncGenerator.prototype.return = function (arg) { 1704 1705 return this._invoke("return", arg); 1706 1707 }; 1708 1709 1710 1711 return { 1712 1713 wrap: function (fn) { 1714 1715 return function () { 1716 1717 return new AsyncGenerator(fn.apply(this, arguments)); 1718 1719 }; 1720 1721 }, 1722 1723 await: function (value) { 1724 1725 return new AwaitValue(value); 1726 1727 } 1728 1729 }; 1730 1731}(); 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743var classCallCheck = function (instance, Constructor) { 1744 1745 if (!(instance instanceof Constructor)) { 1746 1747 throw new TypeError("Cannot call a class as a function"); 1748 1749 } 1750 1751}; 1752 1753 1754 1755var createClass = function () { 1756 1757 function defineProperties(target, props) { 1758 1759 for (var i = 0; i < props.length; i++) { 1760 1761 var descriptor = props[i]; 1762 1763 descriptor.enumerable = descriptor.enumerable || false; 1764 1765 descriptor.configurable = true; 1766 1767 if ("value" in descriptor) descriptor.writable = true; 1768 1769 Object.defineProperty(target, descriptor.key, descriptor); 1770 1771 } 1772 1773 } 1774 1775 1776 1777 return function (Constructor, protoProps, staticProps) { 1778 1779 if (protoProps) defineProperties(Constructor.prototype, protoProps); 1780 1781 if (staticProps) defineProperties(Constructor, staticProps); 1782 1783 return Constructor; 1784 1785 }; 1786 1787}(); 1788 1789 1790 1791/* Ticker Class - Controls each instance of a ticker. */ 1792 1793 1794 1795var log$2 = logger('class'); 1796 1797 1798 1799/* TODO: Port over to private fields 1800 1801 * - Requires Gulp setup 1802 1803 **/ 1804 1805 1806 1807var Ticker = function () { 1808 1809 function Ticker(elem, settings) { 1810 1811 classCallCheck(this, Ticker); 1812 1813 1814 1815 this.elem = elem; 1816 1817 1818 1819 this.settings = settings; 1820 1821 1822 1823 this.__offset = 0; 1824 1825 this.__pauseTracker = 0; 1826 1827 1828 1829 this.build(); 1830 1831 } 1832 1833 1834 1835 createClass(Ticker, [{ 1836 1837 key: 'build', 1838 1839 value: function build() { 1840 1841 var _this = this; 1842 1843 1844 1845 if (!this.started) { 1846 1847 this.started = true; 1848 1849 1850 1851 //region Build Track 1852 1853 var track = document.createElement('div'); // <div class="js-ticker-track">; 1854 1855 track.className = 'js-ticker-track'; 1856 1857 1858 1859 this.elem.addClass('js-ticker'); 1860 1861 this.elem.children(this.settings.item).addClass('js-ticker-item').appendTo(track); 1862 1863 1864 1865 this.elem.append(track); 1866 1867 //endregion 1868 1869 1870 1871 //region Init Variables 1872 1873 this.track = this.elem.find('.js-ticker-track'); 1874 1875 this.__items = this.track.children('.js-ticker-item'); 1876 1877 1878 1879 this.__first = this.__items.first(); 1880 1881 this.__first.attr('data-first', true); 1882 1883 //endregion 1884 1885 1886 1887 //region Clone For Scale 1888 1889 var targetWidth = this.elem.width() + this.__first.width(); 1890 1891 1892 1893 log$2('(Pre Clones) Target Width: %d, Actual: %d', targetWidth, this.elem[0].scrollWidth); 1894 1895 1896 1897 while (this.elem[0].scrollWidth < targetWidth) { 1898 1899 this.__items.each(function (i) { 1900 1901 _this.track.append(_this.__items.eq(i).clone()); 1902 1903 }); 1904 1905 } 1906 1907 1908 1909 log$2('(Post Clones) Target Width: %d, Actual: %d', targetWidth, this.elem[0].scrollWidth); 1910 1911 //endregion 1912 1913 1914 1915 //region Init Events 1916 1917 // Insurance to prevent doubling up on enter triggers 1918 1919 /* FIXME: This looks... un... safe. */ 1920 1921 var initHover = function initHover() { 1922 1923 _this.elem.one('mouseenter', function () { 1924 1925 _this.__pauseTracker++; 1926 1927 _this.elem.one('mouseleave', function () { 1928 1929 _this.__pauseTracker--; 1930 1931 initHover(); 1932 1933 }); 1934 1935 }); 1936 1937 }; 1938 1939 1940 1941 if (this.settings.pauseOnHover) initHover(); 1942 1943 1944 1945 /* TODO: Pause on focus and reset slider position for ADA 1946 1947 * - Also need a solution on keyboard navigation 1948 1949 **/ 1950 1951 //endregion 1952 1953 1954 1955 //region Enable Ticker 1956 1957 this.elem.addClass('active'); 1958 1959 this.elem.data('ticker', this); 1960 1961 1962 1963 brain.tickers.push(this); 1964 1965 //endregion 1966 1967 } 1968 1969 } 1970 1971 }, { 1972 1973 key: 'advance', 1974 1975 value: function advance() { 1976 1977 var _this2 = this; 1978 1979 1980 1981 this.__width = this.__first.outerWidth(); 1982 1983 if (!this.__pauseTracker) { 1984 1985 1986 1987 this.__offset += this.settings.speed / brain.fps; 1988 1989 1990 1991 /* TODO: Need a solution to go in reverse */ 1992 1993 if (this.__offset > this.__width) { 1994 1995 this.__offset = 0; 1996 1997 this.__first.appendTo(this.track); 1998 1999 this.__first = this.track.children('.js-ticker-item').first(); 2000 2001 if (this.settings.pauseAt === 'item' || this.settings.pauseAt === 'track' && this.__first.data('first')) { 2002 2003 this.__pauseTracker++; 2004 2005 setTimeout(function () { 2006 2007 return _this2.__pauseTracker--; 2008 2009 }, this.settings.delay); 2010 2011 } 2012 2013 } 2014 2015 2016
2017 var transformProp = getSupportedTransform(); 2018 2019 2020 2021 if (transformProp) { 2022 2023 this.track.css(transformProp, 'translateX(' + -this.__offset + 'px)'); 2024 2025 } else { 2026 2027 this.track.css('left', -this.__offset + 'px'); 2028 2029 } 2030 2031 } 2032 2033 } 2034 2035 }, { 2036 2037 key: 'pause', 2038 2039 value: function pause() { 2040 2041 if (!this.__manuallyPaused) { 2042 2043 this.__pauseTracker++; 2044 2045 this.__manuallyPaused = true; 2046 2047 } 2048 2049 } 2050 2051 }, { 2052 2053 key: 'play', 2054 2055 value: function play() { 2056 2057 if (this.__manuallyPaused) { 2058 2059 this.__pauseTracker--; 2060 2061 this.__manuallyPaused = false; 2062 2063 } 2064 2065 } 2066 2067 }, { 2068 2069 key: 'toggle', 2070 2071 value: function toggle() { 2072 2073 if (this.__manuallyPaused) { 2074 2075 this.play(); 2076 2077 } else { 2078 2079 this.pause(); 2080 2081 } 2082 2083 } 2084 2085 }], [{ 2086 2087 key: 'version', 2088 2089 get: function get$$1() { 2090 2091 return '0.0.1'; 2092 2093 } 2094 2095 }]); 2096 2097 return Ticker; 2098 2099}(); 2100 2101 2102 2103/** 2104 2105 * Small jQuery Plugin create by Quangdao Nguyen 2106 2107 */ 2108 2109 2110 2111var log = logger('entry'); 2112 2113 2114 2115(function ($) { 2116 2117 'use strict'; 2118 2119 2120 2121 if (!$) return console.warn('Whoa there, buddy! Looks like you included the jQuery Ticker plugin without including jQuery first.'); 2122 2123 2124 2125 $.ticker = function (elem, settings) { 2126 2127 return new Ticker($(elem), settings); 2128 2129 }; 2130 2131 2132 2133 $.fn.ticker = function () { 2134 2135 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2136 2137 2138 2139 return this.each(function () { 2140 2141 $.ticker(this, $.extend(true, {}, defaultOptions, overrides)); 2142 2143 }); 2144 2145 }; 2146 2147 2148 2149 brain.init($); 2150 2151})(typeof jQuery !== 'undefined' ? jQuery : null); 2152
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.