PageSourceSearch

https://brandshop.nyls.edu/wp-content/themes/monument-valley/assets/js/scripts-sticky.js?ver=2.0.7

js nyls.edu collected 2026-10-02 02:30:51 UTC 3,693 bytes, 189 lines download raw bytes

1/**
2 * Sticky header and row
3 *
4 * @package    Monument Valley
5 * @copyright  WebMan Design, Oliver Juhas
6 *
7 * @since    1.0.0
8 * @version  1.8.5
9 */
10
11( function( $ ) {
12
13	'use strict';
14
15	var
16		$breakpoints = ( 'undefined' !== typeof $monumentValleyBreakpoints ) ? ( $monumentValleyBreakpoints ) : ( { 'xl' : 1280 } );
17
18	if (
19		$( 'body' ).hasClass( 'has-sticky-header' )
20		&& parseInt( $breakpoints['xl'] ) <= window.innerWidth
21	) {
22
23
24
25
26
27		/**
28		 * Scrolling classes on BODY
29		 */
30
31			/**
32			 * Cache and variables
33			 */
34
35				var
36					$window                 = $( window ),
37					$body                   = $( 'body' ),
38					$didScroll              = false,
39					$lastScrollTop          = 0,
40					$headerHeightMultiplier = .5,
41					$header                 = $( document.getElementById( 'masthead' ) ),
42					$headerHeight           = 0,
43					$headerOffset           = 0,
44					$scrollingOffset        = 0,
45					$screenResized          = true,
46					$headerPlaceholder      = $( '<div id="site-header-placeholder" class="site-header-placeholder" />' ).insertBefore( '#masthead' );
47
48
49
50			/**
51			 * Fire on browser window scroll
52			 *
53			 * Reset on browser window resize.
54			 */
55
56				$window
57					.on( 'load', function() {
58
59						// Helper variables
60
61							$headerHeight    = $header.outerHeight();
62							$headerOffset    = $header.offset();
63							$scrollingOffset = $headerHeight * $headerHeightMultiplier + $headerOffset.top - $window.scrollTop();
64
65						// Processing
66
67							$headerPlaceholder
68								.css( 'height', $headerHeight );
69
70					} )
71					.on( 'resize orientationchange', function( e ) {
72
73						// Processing
74
75							$didScroll       = false;
76							$lastScrollTop   = 0;
77							$headerHeight    = $header.outerHeight();
78							$scrollingOffset = $headerHeight * $headerHeightMultiplier + $headerOffset.top;
79							$screenResized   = true;
80
81					} )
82					.on( 'scroll', function( e ) {
83
84						// Processing
85
86							$didScroll = true;
87
88					} );
89
90				setInterval( function() {
91
92					// Processing
93
94						// Fixing Chrome inline styles after JavaScript loaded
95
96							$( '#masthead[style]' )
97								.removeAttr( 'style' );
98
99						// Scrolling actions
100
101							if ( $didScroll ) {
102
103								hasScrolled();
104
105								$didScroll = false;
106
107							}
108
109				}, 250 );
110
111
112
113			/**
114			 * Actions when scrolling screen
115			 */
116			function hasScrolled() {
117
118				// Requirements check
119
120					if (
121							$screenResized
122							&& parseInt( $breakpoints['xl'] ) > window.innerWidth
123						) {
124						return;
125					}
126
127
128				// Helper variables
129
130					var
131						$st = $window.scrollTop();
132
133
134				// Processing
135
136					// Do nothing and remove the scrolling class when not scrolled enough
137
138						if ( $st < $scrollingOffset || $st < 5 ) {
139
140							$body
141								.removeClass( 'scrolling-up scrolling-down has-scrolled' );
142
143							// Setting up global vars
144
145								$lastScrollTop = $st;
146								$screenResized = false;
147
148							return;
149
150						}
151
152					// Apply the scrolling class
153
154						$body
155							.addClass( 'has-scrolled' );
156
157						if ( $st < $lastScrollTop ) {
158
159							$body
160								.addClass( 'scrolling-up' )
161								.removeClass( 'scrolling-down' );
162
163						} else {
164
165							$body
166								.removeClass( 'scrolling-up' )
167								.addClass( 'scrolling-down' );
168
169						}
170
171					// Setting sticky header placeholder height
172
173						$headerPlaceholder
174							.css( 'height', $headerHeight );
175
176					// Setting up global vars
177
178						$lastScrollTop = $st;
179						$screenResized = false;
180
181			} // /hasScrolled
182
183
184
185
186
187	}
188
189} )( 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.