PageSourceSearch

https://matexmotors.com/Scripts/js/sticky.js

js matexmotors.com collected 2026-10-02 00:53:16 UTC 7,933 bytes, 240 lines download raw bytes

1(function(factory) {
2	if (typeof define === 'function' && define.amd) {
3		define(['jquery'], factory)
4	} else if (typeof module === 'object' && module.exports) {
5		module.exports = factory(require('jquery'))
6	} else {
7		factory(jQuery)
8	}
9	$(".horizontal-main").sticky({
10		topSpacing: 0
11	})
12	$(".horizontal-header").sticky({
13		topSpacing: 0
14	})
15}(function($) {
16	var slice = Array.prototype.slice;
17	var splice = Array.prototype.splice;
18	var defaults = {
19			topSpacing: 0,
20			bottomSpacing: 0,
21			className: 'is-sticky',
22			wrapperClassName: 'sticky-wrapper',
23			center: !1,
24			getWidthFrom: '',
25			widthFromWrapper: !0,
26			responsiveWidth: !1,
27			zIndex: 'inherit'
28		},
29		$window = $(window),
30		$document = $(document),
31		sticked = [],
32		windowHeight = $window.height(),
33		scroller = function() {
34			var scrollTop = $window.scrollTop(),
35				documentHeight = $document.height(),
36				dwh = documentHeight - windowHeight,
37				extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
38			for (var i = 0, l = sticked.length; i < l; i++) {
39				var s = sticked[i],
40					elementTop = s.stickyWrapper.offset().top,
41					etse = elementTop - s.topSpacing - extra;
42				s.stickyWrapper.css('height', s.stickyElement.outerHeight());
43				if (scrollTop <= etse) {
44					if (s.currentTop !== null) {
45						s.stickyElement.css({
46							'width': '',
47							'position': '',
48							'top': '',
49							'z-index': ''
50						});
51						s.stickyElement.parent().removeClass(s.className);
52						s.stickyElement.trigger('sticky-end', [s]);
53						s.currentTop = null
54					}
55				} else {
56					var newTop = documentHeight - s.stickyElement.outerHeight() - s.topSpacing - s.bottomSpacing - scrollTop - extra;
57					if (newTop < 0) {
58						newTop = newTop + s.topSpacing
59					} else {
60						newTop = s.topSpacing
61					}
62					if (s.currentTop !== newTop) {
63						var newWidth;
64						if (s.getWidthFrom) {
65							padding = s.stickyElement.innerWidth() - s.stickyElement.width();
66							newWidth = $(s.getWidthFrom).width() - padding || null
67						} else if (s.widthFromWrapper) {
68							newWidth = s.stickyWrapper.width()
69						}
70						if (newWidth == null) {
71							newWidth = s.stickyElement.width()
72						}
73						s.stickyElement.css('width', newWidth).css('position', 'fixed').css('top', newTop).css('z-index', s.zIndex);
74						s.stickyElement.parent().addClass(s.className);
75						if (s.currentTop === null) {
76							s.stickyElement.trigger('sticky-start', [s])
77						} else {
78							s.stickyElement.trigger('sticky-update', [s])
79						}
80						if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) {
81							s.stickyElement.trigger('sticky-bottom-reached', [s])
82						} else if (s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) {
83							s.stickyElement.trigger('sticky-bottom-unreached', [s])
84						}
85						s.currentTop = newTop
86					}
87					var stickyWrapperContainer = s.stickyWrapper.parent();
88					var unstick = (s.stickyElement.offset().top + s.stickyElement.outerHeight() >= stickyWrapperContainer.offset().top + stickyWrapperContainer.outerHeight()) && (s.stickyElement.offset().top <= s.topSpacing);
89					if (unstick) {
90						s.stickyElement.css('position', 'absolute').css('top', '').css('bottom', 0).css('z-index', '')
91					} else {
92						s.stickyElement.css('position', 'fixed').css('top', newTop).css('bottom', '').css('z-index', s.zIndex)
93					}
94				}
95			}
96		},
97		resizer = function() {
98			windowHeight = $window.height();
99			for (var i = 0, l = sticked.length; i < l; i++) {
100				var s = sticked[i];
101				var newWidth = null;
102				if (s.getWidthFrom) {
103					if (s.responsiveWidth) {
104						newWidth = $(s.getWidthFrom).width()
105					}
106				} else if (s.widthFromWrapper) {
107					newWidth = s.stickyWrapper.width()
108				}
109				if (newWidth != null) {
110					s.stickyElement.css('width', newWidth)
111				}
112			}
113		},
114		methods = {
115			init: function(options) {
116				return this.each(function() {
117					var o = $.extend({}, defaults, options);
118					var stickyElement = $(this);
119					var stickyId = stickyElement.attr('id');
120					var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName;
121					var wrapper = $('<div></div>').attr('id', wrapperId).addClass(o.wrapperClassName);
122					stickyElement.wrapAll(function() {
123						if ($(this).parent("#" + wrapperId).length == 0) {
124							return wrapper
125						}
126					});
127					var stickyWrapper = stickyElement.parent();
128					if (o.center) {
129						stickyWrapper.css({
130							width: stickyElement.outerWidth(),
131							marginLeft: "auto",
132							marginRight: "auto"
133						})
134					}
135					if (stickyElement.css("float") === "right") {
136						stickyElement.css({
137							"float": "none"
138						}).parent().css({
139							"float": "right"
140						})
141					}
142					o.stickyElement = stickyElement;
143					o.stickyWrapper = stickyWrapper;
144					o.currentTop = null;
145					sticked.push(o);
146					methods.setWrapperHeight(this);
147					methods.setupChangeListeners(this)
148				})
149			},
150			setWrapperHeight: function(stickyElement) {
151				var element = $(stickyElement);
152				var stickyWrapper = element.parent();
153				if (stickyWrapper) {
154					stickyWrapper.css('height', element.outerHeight())
155				}
156			},
157			setupChangeListeners: function(stickyElement) {
158				if (window.MutationObserver) {
159					var mutationObserver = new window.MutationObserver(function(mutations) {
160						if (mutations[0].addedNodes.length || mutations[0].removedNodes.length) {
161							methods.setWrapperHeight(stickyElement)
162						}
163					});
164					mutationObserver.observe(stickyElement, {
165						subtree: !0,
166						childList: !0
167					})
168				} else {
169					if (window.addEventListener) {
170						stickyElement.addEventListener('DOMNodeInserted', function() {
171							methods.setWrapperHeight(stickyElement)
172						}, !1);
173						stickyElement.addEventListener('DOMNodeRemoved', function() {
174							methods.setWrapperHeight(stickyElement)
175						}, !1)
176					} else if (window.attachEvent) {
177						stickyElement.attachEvent('onDOMNodeInserted', function() {
178							methods.setWrapperHeight(stickyElement)
179						});
180						stickyElement.attachEvent('onDOMNodeRemoved', function() {
181							methods.setWrapperHeight(stickyElement)
182						})
183					}
184				}
185			},
186			update: scroller,
187			unstick: function(options) {
188				return this.each(function() {
189					var that = this;
190					var unstickyElement = $(that);
191					var removeIdx = -1;
192					var i = sticked.length;
193					while (i-- > 0) {
194						if (sticked[i].stickyElement.get(0) === that) {
195							splice.call(sticked, i, 1);
196							removeIdx = i
197						}
198					}
199					if (removeIdx !== -1) {
200						unstickyElement.unwrap();
201						unstickyElement.css({
202							'width': '',
203							'position': '',
204							'top': '',
205							'float': '',
206							'z-index': ''
207						})
208					}
209				})
210			}
211		};
212	if (window.addEventListener) {
213		window.addEventListener('scroll', scroller, !1);
214		window.addEventListener('resize', resizer, !1)
215	} else if (window.attachEvent) {
216		window.attachEvent('onscroll', scroller);
217		window.attachEvent('onresize', resizer)
218	}
219	$.fn.sticky = function(method) {
220		if (methods[method]) {
221			return methods[method].apply(this, slice.call(arguments, 1))
222		} else if (typeof method === 'object' || !method) {
223			return methods.init.apply(this, arguments)
224		} else {
225			$.error('Method ' + method + ' does not exist on jQuery.sticky')
226		}
227	};
228	$.fn.unstick = function(method) {
229		if (methods[method]) {
230			return methods[method].apply(this, slice.call(arguments, 1))
231		} else if (typeof method === 'object' || !method) {
232			return methods.unstick.apply(this, arguments)
233		} else {
234			$.error('Method ' + method + ' does not exist on jQuery.sticky')
235		}
236	};
237	$(function() {
238		setTimeout(scroller, 0)
239	})
240}))

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.