-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
72 lines (59 loc) · 2.04 KB
/
main.js
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
jQuery(document).ready(function($){
var orginal_height = typeof(orginal_height==='undefined') || $('body').hasClass('fixed_sticky_active')==false ? $('#site-logo-inner').height() : orginal_height;
function sticky_header_oceanwp(){
var style = typeof(sticky_header_style) !== 'undefined' && sticky_header_style == 'shrink' ? 'shrink' : 'float';
var site_header = $('#site-header');
var wpadmin_height = $('#wpadminbar').css('position') == 'fixed' && $('#wpadminbar').height() > 0 ? $('#wpadminbar').height() : 0;
var top_bars = $('#wpadminbar').css('position') == 'fixed' ? $('#top-bar-wrap').height() : $('#top-bar-wrap').height() + $('#wpadminbar').height();
if (Number.isNaN(top_bars)){
top_bars = $('#top-bar-wrap').height();
}
top_bars = top_bars || 0;
var header_status = $(window).scrollTop() >= top_bars;
var header_padding = site_header.height();
if (style == 'float'){
if (!header_status){
site_header.css({
'position': 'relative',
'top': '0',
});
site_header.next().css('margin-top', '0');
}else{
site_header.css({
'position': 'fixed',
'top': wpadmin_height,
'width': '100%',
'z-index': '998',
});
site_header.next().css('margin-top', header_padding);
}
}
if (style == 'shrink'){
if (!header_status){
site_header.css({
'position': 'relative',
'top': '0',
});
$('body').removeClass('fixed_sticky_active');
site_header.next().css('margin-top', '0');
}else{
site_header.css({
'position': 'fixed',
'top': wpadmin_height,
'width': '100%',
'z-index': '998',
});
site_header.next().css('margin-top', header_padding);
$('body').addClass('fixed_sticky_active');
}
}
}
$(window).resize(function(){
$('body').removeClass('fixed_sticky_active');
sticky_header_oceanwp();
});
$(window).scroll(function(){
sticky_header_oceanwp();
});
sticky_header_oceanwp();
});