-
Notifications
You must be signed in to change notification settings - Fork 13
/
reposition first page section background so header does not hide it.html
87 lines (44 loc) · 2.12 KB
/
reposition first page section background so header does not hide it.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<script>
$( ( ) => {
/*
begin reposition first page section background so header does not hide it
License : < https://tinyurl.com/s872fb68 >
Version : 0.2d0
SS Version : 7.1
Dependencies : jQuery
By : Thomas Creedon < http://www.tomsWeb.consulting/ >
*/
// increase section height the same amount the image is moved down
const increaseSectionHeight = false;
// do not change anything below, there be the borg here
$( window )
.resize ( function ( ) {
const h = $( '#header' ).height ( );
const $firstPageSection =
$( ':not( #footer-sections ) > .page-section:first' );
if ( ! $firstPageSection.length ) return; // bail if no first section
const selector = '.section-background img, ' +
'.section-background .sqs-video-background';
const $e = $( selector, $firstPageSection );
$e.css ( 'top', h + 'px' );
// bail if no section height increase
if ( ! increaseSectionHeight ) return;
let minHeight = 0;
switch ( true ) {
case $firstPageSection.hasClass ( 'section-height--medium' ) :
minHeight = 66;
break;
case $firstPageSection.hasClass ( 'section-height--small' ) :
minHeight = 33;
break;
default :
minHeight = 100;
}
if ( minHeight )
$firstPageSection.css ( 'min-height', 'calc( ' + minHeight +
'vh + ' + h + 'px )' );
} )
.resize ( );
// end reposition first page section background so header does not hide it
} );
</script>