PageSourceSearch

https://buckinghamcrossfit.ca/wp-content/themes/Impreza/framework/js/jquery.parallax.js?ver=3.3.2

js buckinghamcrossfit.ca collected 2026-10-08 03:29:20 UTC 6,286 bytes, 196 lines download raw bytes

1/*
2 Plugin: jQuery Parallax
3 Version 1.1.3
4 Author: Ian Lunn
5 Twitter: @IanLunn
6 Author URL: http://www.ianlunn.co.uk/
7 Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/
8
9 (Contains lots of UpSolution's modifications)
10
11 Dual licensed under the MIT and GPL licenses:
12 http://www.opensource.org/licenses/mit-license.php
13 http://www.gnu.org/licenses/gpl.html
14 */
15
16(function( $ ){
17	var $window = $(window),
18		windowHeight = $window.height();
19
20	$.fn.parallax = function(xposParam){
21		this.each(function(){
22			var $container = $(this),
23				$this = $container.children('.l-section-img, .l-titlebar-img'),
24				speedFactor,
25				offsetFactor = 0,
26				getHeight,
27				topOffset = 0,
28				containerHeight = 0,
29				containerWidth = 0,
30			// Disable parallax on certain screen/img ratios
31				disableParallax = false,
32				parallaxIsDisabled = false,
33			// Base image width and height (if can be achieved)
34				baseImgHeight = 0,
35				baseImgWidth = 0,
36			// Backgroud-size cover? and current image size (counted)
37				isBgCover = ($this.css('background-size') == 'cover'),
38				originalBgPos = $this.css('background-position'),
39				curImgHeight = 0,
40				reversed = $container.hasClass('parallaxdir_reversed'),
41				baseSpeedFactor = reversed ? -0.1 : 0.61,
42				xpos,
43				outerHeight = true;
44			if ($this.length == 0) return;
45
46			// setup defaults if arguments aren't specified
47			if (xposParam === undefined) {
48				xpos = "50%";
49			} else {
50				xpos = xposParam;
51			}
52
53			if ($container.hasClass('parallax_xpos_right')) {
54				xpos = "100%";
55			} else if ($container.hasClass('parallax_xpos_left')) {
56				xpos = "0%";
57			}
58
59			if (outerHeight){
60				getHeight = function(jqo){
61					return jqo.outerHeight(true);
62				};
63			} else {
64				getHeight = function(jqo){
65					return jqo.height();
66				};
67			}
68
69			// Count background image size
70			function getBackgroundSize(callback){
71				var img = new Image(),
72				// here we will place image's width and height
73					width, height,
74				// here we get the size of the background and split it to array
75					backgroundSize = ($this.css('background-size') || ' ').split(' '),
76					backgroundWidthAttr = $this.attr('data-img-width'),
77					backgroundHeightAttr = $this.attr('data-img-height');
78
79				if (backgroundWidthAttr != '') width = parseInt(backgroundWidthAttr);
80				if (backgroundHeightAttr != '') height = parseInt(backgroundHeightAttr);
81
82				if (width !== undefined && height !== undefined){
83					// Image is not needed
84					return callback({ width: width, height: height });
85				}
86
87				// checking if width was set to pixel value
88				if (/px/.test(backgroundSize[0])) width = parseInt(backgroundSize[0]);
89				// checking if width was set to percent value
90				if (/%/.test(backgroundSize[0])) width = $this.parent().width() * (parseInt(backgroundSize[0]) / 100);
91				// checking if height was set to pixel value
92				if (/px/.test(backgroundSize[1])) height = parseInt(backgroundSize[1]);
93				// checking if height was set to percent value
94				if (/%/.test(backgroundSize[1])) height = $this.parent().height() * (parseInt(backgroundSize[0]) / 100);
95
96				if (width !== undefined && height !== undefined){
97					// Image is not needed
98					return callback({ width: width, height: height });
99				}
100
101				// Image is needed
102				img.onload = function () {
103					// check if width was set earlier, if not then set it now
104					if (typeof width == 'undefined') width = this.width;
105					// do the same with height
106					if (typeof height == 'undefined') height = this.height;
107					// call the callback
108					callback({ width: width, height: height });
109				};
110				// extract image source from css using one, simple regex
111				// src should be set AFTER onload handler
112				img.src = ($this.css('background-image') || '').replace(/url\(['"]*(.*?)['"]*\)/g, '$1');
113			}
114			function update(){
115				if (disableParallax){
116					if ( ! parallaxIsDisabled){
117						$this.css('backgroundPosition', originalBgPos);
118						$container.usMod('parallax', 'fixed');
119						parallaxIsDisabled = true;
120					}
121					return;
122				}else{
123					if (parallaxIsDisabled){
124						$container.usMod('parallax', 'ver');
125						parallaxIsDisabled = false;
126					}
127				}
128				if (isNaN(speedFactor))
129					return;
130
131				var pos = $window.scrollTop();
132				// Check if totally above or totally below viewport
133				if ((topOffset + containerHeight < pos) || (pos < topOffset - windowHeight)) return;
134				$this.css('backgroundPosition', xpos + " " + (offsetFactor + speedFactor * (topOffset - pos)) + "px");
135
136
137			}
138			function resize(){
139				setTimeout(function(){
140					windowHeight = $window.height();
141					containerHeight = getHeight($this);
142					containerWidth = $this.width();
143
144
145					if ($window.width() <= $us.canvasOptions.disableEffectsWidth) {
146						disableParallax = true;
147					} else {
148						disableParallax = false;
149						if (isBgCover){
150							if (baseImgWidth / baseImgHeight <= containerWidth / containerHeight){
151								// Resizing by width
152								curImgHeight = baseImgHeight * ($this.width() / baseImgWidth);
153								disableParallax = false;
154							}
155							else {
156								disableParallax = true;
157							}
158						}
159					}
160
161
162
163					// Improving speed factor to prevent showing image limits
164					if (curImgHeight !== 0){
165						if (baseSpeedFactor >= 0) {
166							speedFactor = Math.min(baseSpeedFactor, curImgHeight / windowHeight);
167							offsetFactor = Math.min(0, .5 * (windowHeight - curImgHeight - speedFactor * (windowHeight - containerHeight)));
168						} else {
169							speedFactor = Math.min(baseSpeedFactor, (windowHeight - containerHeight) / (windowHeight + containerHeight));
170							offsetFactor = Math.max(0, speedFactor * containerHeight);
171						}
172					}else{
173						speedFactor = baseSpeedFactor;
174						offsetFactor = 0;
175					}
176					topOffset = $this.offset().top;
177					update();
178				}, 10);
179			}
180
181			getBackgroundSize(function(sz){
182				curImgHeight = baseImgHeight = sz.height;
183				baseImgWidth = sz.width;
184				resize();
185			});
186
187			$window.bind({scroll: update, load: resize, resize: resize});
188			resize();
189		});
190	};
191
192	//$(function(){
193		jQuery('.parallax_ver').parallax('50%');
194	//});
195
196})(jQuery);

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.