-
Notifications
You must be signed in to change notification settings - Fork 0
/
scroll-menu-topo-stop.html
113 lines (96 loc) · 2.84 KB
/
scroll-menu-topo-stop.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Scroll-Menu-topo Stop</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
var mastHeight = 156,
mastheadWrap = $('#masthead .wrap'),
userAgent = navigator.userAgent,
uaCheck = {
ios: userAgent.match(/(iPhone|iPod|iPad)/),
blackberry: userAgent.match(/BlackBerry/),
android: userAgent.match(/Android/)
},
animSpeed = 4
$(document).scroll(function() {
// define some globals for our methods to hit
scrollDist = document.body.scrollTop,
opacityNum = 1-(scrollDist * (1/mastHeight) - 0.05),
positionNum = Math.floor(scrollDist/animSpeed)
// run our methods
fadeHeader(opacityNum)
});
function fadeHeader() {
// we dont care about this stuff on mobile devices
if (uaCheck.ios || uaCheck.blackberry || uaCheck.android) return
// moving the header around
if (positionNum <= mastHeight) {
mastheadWrap.css('top', positionNum + 'px')
}
// fading master wrap
if (opacityNum > 1) { opacityNum = 1; }
if (opacityNum <= 1 && opacityNum >= 0) {
mastheadWrap.css('opacity', opacityNum)
}
// sticky pattern
$el = $('.pattern');
if ($(this).scrollTop() > mastHeight && $el.css('position') != 'fixed'){
$el.css({'top': '0px', 'position': 'fixed'})
} else if ( $(this).scrollTop() <= mastHeight && $el.css('position') == 'fixed' ) {
$el.css({'position': 'absolute', 'top': mastHeight + 'px'})
}
}
});
</script>
<style type="text/css">
.pattern{
width:100%;
height:31px;
background:#660000;
text-align:center;
color:#fff;
line-height:30px;
position: absolute;
top: 156px;
z-index: 100;
}
#masthead{
width: 100%;
height: 156px;
background: #191818;
}
.conteudo{height:1200px; text-align: right; margin:60px}
body {margin: 0px}
</style>
</head> <!-- COLOCAR CSS pattern -> position, top e z-index -->
<body>
<header id="masthead">
</header>
<div class="pattern">
Texto ou div aqui - Qualquer coisa aki mesmo.
</div>
<div class="conteudo">
bla bla blaxxxxxx<br /><br />
bla bla blayyyyyy<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
bla bla bla<br /><br />
</div>
</body>
</html>