-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (30 loc) · 1.06 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
var navOffsetTop
$(document).ready(function() {
navOffsetTop = $('nav').offset().top
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
$(window).on('scroll', onScroll)
})
function onScroll() {
if (navOffsetTop < $(window).scrollTop() && !$('nav').hasClass('is-fixed-top')) {
$('nav').addClass('is-fixed-top')
$('body').css("padding-top", $('nav').height())
}
if (navOffsetTop > $(window).scrollTop() && $('nav').hasClass('is-fixed-top')) {
$('nav').removeClass('is-fixed-top')
$('body').css("padding-top", 0)
}
}
$(window).on('scroll', function () {
var pixs = $(document).scrollTop()
var scr = pixs/2
pixs = 1- pixs / $('.hero-body').height()/7;
$(".hero-body").css({"opacity": pixs })
$("#hero-title").css({"transform": 'translateY('+scr+'px)'})
});