PageSourceSearch

https://themainstream.uk/wp-content/themes/thegem-elementor/js/jquery.waypoints.js?ver=5.12.3.1

js themainstream.uk collected 2026-10-02 16:09:14 UTC 20,631 bytes, 652 lines download raw bytes

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

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.