1// Generated by CoffeeScript 1.6.2 2/*! 3Waypoints - 4.0.0 4Copyright © 2011-2015 Caleb Troughton 5Licensed under the MIT license. 6https://github.com/imakewebthings/waypoints/blob/master/licenses.txt 7*/ 8(function() { 9 'use strict' 10 11 var keyCounter = 0 12 var allWaypoints = {} 13 14 /* http://imakewebthings.com/waypoints/api/waypoint */ 15 function Waypoint(options) { 16 if (!options) { 17 throw new Error('No options passed to Waypoint constructor') 18 } 19 if (!options.element) { 20 throw new Error('No element option passed to Waypoint constructor') 21 } 22 if (!options.handler) { 23 throw new Error('No handler option passed to Waypoint constructor') 24 } 25 26 this.key = 'waypoint-' + keyCounter 27 this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options) 28 this.element = this.options.element 29 this.adapter = new Waypoint.Adapter(this.element) 30 this.callback = options.handler 31 this.axis = this.options.horizontal ? 'horizontal' : 'vertical' 32 this.enabled = this.options.enabled 33 this.triggerPoint = null 34 this.group = Waypoint.Group.findOrCreate({ 35 name: this.options.group, 36 axis: this.axis 37 }) 38 this.context = Waypoint.Context.findOrCreateByElement(this.options.context) 39 40 if (Waypoint.offsetAliases[this.options.offset]) { 41 this.options.offset = Waypoint.offsetAliases[this.options.offset] 42 } 43 this.group.add(this) 44 this.context.add(this) 45 allWaypoints[this.key] = this 46 keyCounter += 1 47 } 48 49 /* Private */ 50 Waypoint.prototype.queueTrigger = function(direction) { 51 this.group.queueTrigger(this, direction) 52 } 53 54 /* Private */ 55 Waypoint.prototype.trigger = function(args) { 56 if (!this.enabled) { 57 return 58 } 59 if (this.callback) { 60 this.callback.apply(this, args) 61 } 62 } 63 64 /* Public */ 65 /* http://imakewebthings.com/waypoints/api/destroy */ 66 Waypoint.prototype.destroy = function() { 67 this.context.remove(this) 68 this.group.remove(this) 69 delete allWaypoints[this.key] 70 } 71 72 /* Public */ 73 /* http://imakewebthings.com/waypoints/api/disable */ 74 Waypoint.prototype.disable = function() { 75 this.enabled = false 76 return this 77 } 78 79 /* Public */ 80 /* http://imakewebthings.com/waypoints/api/enable */ 81 Waypoint.prototype.enable = function() { 82 this.context.refresh() 83 this.enabled = true 84 return this 85 } 86 87 /* Public */ 88 /* http://imakewebthings.com/waypoints/api/next */ 89 Waypoint.prototype.next = function() { 90 return this.group.next(this) 91 } 92 93 /* Public */ 94 /* http://imakewebthings.com/waypoints/api/previous */ 95 Waypoint.prototype.previous = function() { 96 return this.group.previous(this) 97 } 98 99 /* Private */ 100 Waypoint.invokeAll = function(method) { 101 var allWaypointsArray = []
102 for (var waypointKey in allWaypoints) { 103 allWaypointsArray.push(allWaypoints[waypointKey]) 104 } 105 for (var i = 0, end = allWaypointsArray.length; i < end; i++) { 106 allWaypointsArray[i][method]() 107 } 108 } 109 110 /* Public */ 111 /* http://imakewebthings.com/waypoints/api/destroy-all */ 112 Waypoint.destroyAll = function() { 113 Waypoint.invokeAll('destroy') 114 } 115 116 /* Public */ 117 /* http://imakewebthings.com/waypoints/api/disable-all */ 118 Waypoint.disableAll = function() { 119 Waypoint.invokeAll('disable') 120 } 121 122 /* Public */ 123 /* http://imakewebthings.com/waypoints/api/enable-all */ 124 Waypoint.enableAll = function() { 125 Waypoint.invokeAll('enable') 126 } 127 128 /* Public */ 129 /* http://imakewebthings.com/waypoints/api/refresh-all */ 130 Waypoint.refreshAll = function() { 131 Waypoint.Context.refreshAll() 132 } 133 134 /* Public */ 135 /* http://imakewebthings.com/waypoints/api/viewport-height */ 136 Waypoint.viewportHeight = function() { 137 return window.innerHeight || document.documentElement.clientHeight 138 } 139 140 /* Public */ 141 /* http://imakewebthings.com/waypoints/api/viewport-width */ 142 Waypoint.viewportWidth = function() { 143 return document.documentElement.clientWidth 144 } 145 146 Waypoint.adapters = [] 147 148 Waypoint.defaults = { 149 context: window, 150 continuous: true, 151 enabled: true, 152 group: 'default', 153 horizontal: false, 154 offset: 0 155 } 156 157 Waypoint.offsetAliases = { 158 'bottom-in-view': function() { 159 return this.context.innerHeight() - this.adapter.outerHeight() 160 }, 161 'right-in-view': function() { 162 return this.context.innerWidth() - this.adapter.outerWidth() 163 } 164 } 165 166 window.Waypoint = Waypoint 167}()) 168;(function() { 169 'use strict' 170 171 function requestAnimationFrameShim(callback) { 172 window.setTimeout(callback, 1000 / 60) 173 } 174 175 var keyCounter = 0 176 var contexts = {} 177 var Waypoint = window.Waypoint 178 var oldWindowLoad = window.onload 179 180 /* http://imakewebthings.com/waypoints/api/context */ 181 function Context(element) { 182 this.element = element 183 this.Adapter = Waypoint.Adapter 184 this.adapter = new this.Adapter(element) 185 this.key = 'waypoint-context-' + keyCounter 186 this.didScroll = false 187 this.didResize = false 188 this.oldScroll = { 189 x: this.adapter.scrollLeft(), 190 y: this.adapter.scrollTop() 191 } 192 this.waypoints = { 193 vertical: {}, 194 horizontal: {} 195 } 196 197 element.waypointContextKey = this.key 198 contexts[element.waypointContextKey] = this 199 keyCounter += 1 200 201 this.createThrottledScrollHandler() 202 this.createThrottledResizeHandler() 203 } 204 205 /* Private */ 206 Context.prototype.add = function(waypoint) { 207 var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical' 208 this.waypoints[axis][waypoint.key] = waypoint 209 this.refresh() 210 } 211 212 /* Private */ 213 Context.prototype.checkEmpty = function() { 214 var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal) 215 var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical) 216 if (horizontalEmpty && verticalEmpty) { 217 this.adapter.off('.waypoints') 218 delete contexts[this.key] 219 } 220 } 221 222 /* Private */ 223 Context.prototype.createThrottledResizeHandler = function() { 224 var self = this 225 226 function resizeHandler() { 227 self.handleResize() 228 self.didResize = false 229 } 230 231 this.adapter.on('resize.waypoints', function() { 232 if (!self.didResize) { 233 self.didResize = true 234 Waypoint.requestAnimationFrame(resizeHandler) 235 } 236 }) 237 } 238 239 /* Private */ 240 Context.prototype.createThrottledScrollHandler = function() { 241 var self = this 242 function scrollHandler() { 243 self.handleScroll() 244 self.didScroll = false 245 } 246 247 this.adapter.on('scroll.waypoints', function() { 248 if (!self.didScroll || Waypoint.isTouch) { 249 self.didScroll = true 250 Waypoint.requestAnimationFrame(scrollHandler) 251 } 252 }) 253 } 254 255 /* Private */ 256 Context.prototype.handleResize = function() { 257 Waypoint.Context.refreshAll() 258 } 259 260 /* Private */ 261 Context.prototype.handleScroll = function() { 262 var triggeredGroups = {} 263 var axes = { 264 horizontal: { 265 newScroll: this.adapter.scrollLeft(), 266 oldScroll: this.oldScroll.x, 267 forward: 'right', 268 backward: 'left' 269 }, 270 vertical: { 271 newScroll: this.adapter.scrollTop(), 272 oldScroll: this.oldScroll.y, 273 forward: 'down', 274 backward: 'up' 275 } 276 } 277 278 for (var axisKey in axes) { 279 var axis = axes[axisKey] 280 var isForward = axis.newScroll > axis.oldScroll 281 var direction = isForward ? axis.forward : axis.backward 282
283 for (var waypointKey in this.waypoints[axisKey]) { 284 var waypoint = this.waypoints[axisKey][waypointKey] 285 var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint 286 var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint 287 var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint 288 var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint 289 if (crossedForward || crossedBackward) { 290 waypoint.queueTrigger(direction) 291 triggeredGroups[waypoint.group.id] = waypoint.group 292 } 293 } 294 } 295 296 for (var groupKey in triggeredGroups) { 297 triggeredGroups[groupKey].flushTriggers() 298 } 299 300 this.oldScroll = { 301 x: axes.horizontal.newScroll, 302 y: axes.vertical.newScroll 303 } 304 } 305 306 /* Private */ 307 Context.prototype.innerHeight = function() { 308 /*eslint-disable eqeqeq */ 309 if (this.element == this.element.window) { 310 return Waypoint.viewportHeight() 311 } 312 /*eslint-enable eqeqeq */ 313 return this.adapter.innerHeight() 314 } 315 316 /* Private */ 317 Context.prototype.remove = function(waypoint) { 318 delete this.waypoints[waypoint.axis][waypoint.key] 319 this.checkEmpty() 320 } 321 322 /* Private */ 323 Context.prototype.innerWidth = function() { 324 /*eslint-disable eqeqeq */ 325 if (this.element == this.element.window) { 326 return Waypoint.viewportWidth() 327 } 328 /*eslint-enable eqeqeq */ 329 return this.adapter.innerWidth() 330 } 331 332 /* Public */ 333 /* http://imakewebthings.com/waypoints/api/context-destroy */ 334 Context.prototype.destroy = function() { 335 var allWaypoints = [] 336 for (var axis in this.waypoints) {
337 for (var waypointKey in this.waypoints[axis]) { 338 allWaypoints.push(this.waypoints[axis][waypointKey]) 339 } 340 } 341 for (var i = 0, end = allWaypoints.length; i < end; i++) { 342 allWaypoints[i].destroy() 343 } 344 } 345 346 /* Public */ 347 /* http://imakewebthings.com/waypoints/api/context-refresh */ 348 Context.prototype.refresh = function() { 349 /*eslint-disable eqeqeq */ 350 var isWindow = this.element == this.element.window 351 /*eslint-enable eqeqeq */ 352 var contextOffset = isWindow ? undefined : this.adapter.offset() 353 var triggeredGroups = {} 354 var axes 355 356 this.handleScroll() 357 axes = { 358 horizontal: { 359 contextOffset: isWindow ? 0 : contextOffset.left, 360 contextScroll: isWindow ? 0 : this.oldScroll.x, 361 contextDimension: this.innerWidth(), 362 oldScroll: this.oldScroll.x, 363 forward: 'right', 364 backward: 'left', 365 offsetProp: 'left' 366 }, 367 vertical: { 368 contextOffset: isWindow ? 0 : contextOffset.top, 369 contextScroll: isWindow ? 0 : this.oldScroll.y, 370 contextDimension: this.innerHeight(), 371 oldScroll: this.oldScroll.y, 372 forward: 'down', 373 backward: 'up', 374 offsetProp: 'top' 375 } 376 } 377 378 for (var axisKey in axes) { 379 var axis = axes[axisKey]
380 for (var waypointKey in this.waypoints[axisKey]) { 381 var waypoint = this.waypoints[axisKey][waypointKey] 382 var adjustment = waypoint.options.offset 383 var oldTriggerPoint = waypoint.triggerPoint 384 var elementOffset = 0 385 var freshWaypoint = oldTriggerPoint == null 386 var contextModifier, wasBeforeScroll, nowAfterScroll 387 var triggeredBackward, triggeredForward 388 389 if (waypoint.element !== waypoint.element.window) { 390 elementOffset = waypoint.adapter.offset()[axis.offsetProp] 391 } 392 393 if (typeof adjustment === 'function') { 394 adjustment = adjustment.apply(waypoint) 395 } 396 else if (typeof adjustment === 'string') { 397 adjustment = parseFloat(adjustment) 398 if (waypoint.options.offset.indexOf('%') > - 1) { 399 adjustment = Math.ceil(axis.contextDimension * adjustment / 100) 400 } 401 } 402 403 contextModifier = axis.contextScroll - axis.contextOffset 404 waypoint.triggerPoint = elementOffset + contextModifier - adjustment 405 wasBeforeScroll = oldTriggerPoint < axis.oldScroll 406 nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll 407 triggeredBackward = wasBeforeScroll && nowAfterScroll 408 triggeredForward = !wasBeforeScroll && !nowAfterScroll 409 410 if (!freshWaypoint && triggeredBackward) { 411 waypoint.queueTrigger(axis.backward) 412 triggeredGroups[waypoint.group.id] = waypoint.group 413 } 414 else if (!freshWaypoint && triggeredForward) { 415 waypoint.queueTrigger(axis.forward) 416 triggeredGroups[waypoint.group.id] = waypoint.group 417 } 418 else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) { 419 waypoint.queueTrigger(axis.forward) 420 triggeredGroups[waypoint.group.id] = waypoint.group 421 } 422 } 423 } 424 425 Waypoint.requestAnimationFrame(function() { 426 for (var groupKey in triggeredGroups) { 427 triggeredGroups[groupKey].flushTriggers() 428 } 429 }) 430 431 return this 432 } 433 434 /* Private */ 435 Context.findOrCreateByElement = function(element) { 436 return Context.findByElement(element) || new Context(element) 437 } 438 439 /* Private */ 440 Context.refreshAll = function() { 441 for (var contextId in contexts) { 442 contexts[contextId].refresh() 443 } 444 } 445 446 /* Public */ 447 /* http://imakewebthings.com/waypoints/api/context-find-by-element */ 448 Context.findByElement = function(element) { 449 return contexts[element.waypointContextKey] 450 } 451 452 window.onload = function() { 453 if (oldWindowLoad) { 454 oldWindowLoad() 455 } 456 Context.refreshAll() 457 } 458 459 Waypoint.requestAnimationFrame = function(callback) { 460 var requestFn = window.requestAnimationFrame || 461 window.mozRequestAnimationFrame || 462 window.webkitRequestAnimationFrame || 463 requestAnimationFrameShim 464 requestFn.call(window, callback) 465 } 466 Waypoint.Context = Context 467}()) 468;(function() { 469 'use strict' 470 471 function byTriggerPoint(a, b) { 472 return a.triggerPoint - b.triggerPoint 473 } 474 475 function byReverseTriggerPoint(a, b) { 476 return b.triggerPoint - a.triggerPoint 477 } 478 479 var groups = { 480 vertical: {}, 481 horizontal: {} 482 } 483 var Waypoint = window.Waypoint 484 485 /* http://imakewebthings.com/waypoints/api/group */ 486 function Group(options) { 487 this.name = options.name 488 this.axis = options.axis 489 this.id = this.name + '-' + this.axis 490 this.waypoints = [] 491 this.clearTriggerQueues() 492 groups[this.axis][this.name] = this 493 } 494 495 /* Private */ 496 Group.prototype.add = function(waypoint) { 497 this.waypoints.push(waypoint) 498 } 499 500 /* Private */ 501 Group.prototype.clearTriggerQueues = function() { 502 this.triggerQueues = { 503 up: [], 504 down: [], 505 left: [], 506 right: [] 507 } 508 } 509 510 /* Private */ 511 Group.prototype.flushTriggers = function() { 512 for (var direction in this.triggerQueues) { 513 var waypoints = this.triggerQueues[direction] 514 var reverse = direction === 'up' || direction === 'left' 515 waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint) 516 for (var i = 0, end = waypoints.length; i < end; i += 1) { 517 var waypoint = waypoints[i] 518 if (waypoint.options.continuous || i === waypoints.length - 1) { 519 waypoint.trigger([direction]) 520 } 521 } 522 } 523 this.clearTriggerQueues() 524 } 525 526 /* Private */ 527 Group.prototype.next = function(waypoint) { 528 this.waypoints.sort(byTriggerPoint) 529 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 530 var isLast = index === this.waypoints.length - 1 531 return isLast ? null : this.waypoints[index + 1] 532 } 533 534 /* Private */ 535 Group.prototype.previous = function(waypoint) { 536 this.waypoints.sort(byTriggerPoint) 537 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 538 return index ? this.waypoints[index - 1] : null 539 } 540 541 /* Private */ 542 Group.prototype.queueTrigger = function(waypoint, direction) { 543 this.triggerQueues[direction].push(waypoint) 544 } 545 546 /* Private */ 547 Group.prototype.remove = function(waypoint) { 548 var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) 549 if (index > -1) { 550 this.waypoints.splice(index, 1) 551 } 552 } 553 554 /* Public */ 555 /* http://imakewebthings.com/waypoints/api/first */ 556 Group.prototype.first = function() { 557 return this.waypoints[0] 558 } 559 560 /* Public */ 561 /* http://imakewebthings.com/waypoints/api/last */ 562 Group.prototype.last = function() { 563 return this.waypoints[this.waypoints.length - 1] 564 } 565 566 /* Private */ 567 Group.findOrCreate = function(options) { 568 return groups[options.axis][options.name] || new Group(options) 569 } 570 571 Waypoint.Group = Group 572}()) 573;(function() { 574 'use strict' 575 576 var $ = window.jQuery 577 var Waypoint = window.Waypoint 578 579 function JQueryAdapter(element) { 580 this.$element = $(element) 581 } 582 583 $.each([
584 'innerHeight', 585 'innerWidth', 586 'off', 587 'offset', 588 'on', 589 'outerHeight', 590 'outerWidth', 591 'scrollLeft', 592 'scrollTop' 593 ], function(i, method) { 594 JQueryAdapter.prototype[method] = function() { 595 var args = Array.prototype.slice.call(arguments) 596 return this.$element[method].apply(this.$element, args) 597 } 598 }) 599 600 $.each([ 601 'extend', 602 'inArray', 603 'isEmptyObject' 604 ], function(i, method) { 605 JQueryAdapter[method] = $[method] 606 }) 607 608 Waypoint.adapters.push({ 609 name: 'jquery', 610 Adapter: JQueryAdapter 611 }) 612 Waypoint.Adapter = JQueryAdapter 613}()) 614;(function() { 615 'use strict' 616 617 var Waypoint = window.Waypoint 618 619 function createExtension(framework) { 620 return function() { 621 var waypoints = [] 622 var overrides = arguments[0] 623 624 if (framework.isFunction(arguments[0])) { 625 overrides = framework.extend({}, arguments[1]) 626 overrides.handler = arguments[0] 627 } 628 629 this.each(function() { 630 var options = framework.extend({}, overrides, { 631 element: this 632 }) 633 if (typeof options.context === 'string') { 634 options.context = framework(this).closest(options.context)[0] 635 } 636 waypoints.push(new Waypoint(options)) 637 }) 638 639 return waypoints 640 } 641 } 642 643 if (window.jQuery) { 644 window.jQuery.fn.waypoint = createExtension(window.jQuery) 645 } 646 if (window.Zepto) { 647 window.Zepto.fn.waypoint = createExtension(window.Zepto) 648 } 649}()) 650;
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.