PageSourceSearch

https://maple-brownabbott.com/wp-content/themes/salient/js/third-party/waypoints.js?ver=4.0.2

js maple-brownabbott.com collected 2026-10-09 23:12:05 UTC 18,621 bytes, 664 lines download raw bytes

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

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.