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