fix the limit of the navigation to the next section
This commit is contained in:
parent
9097d8233c
commit
8e101b5888
1 changed files with 117 additions and 126 deletions
|
|
@ -1,56 +1,47 @@
|
|||
M = {
|
||||
offsetLimit: 100,
|
||||
(M = {
|
||||
offsetLimit: 150,
|
||||
|
||||
init: function() {
|
||||
|
||||
},
|
||||
getWindowOffset: function() {
|
||||
return window.pageYOffset
|
||||
}
|
||||
},
|
||||
C = {
|
||||
getWindowOffset: function () {
|
||||
return window.pageYOffset;
|
||||
},
|
||||
}),
|
||||
(C = {
|
||||
windoOffset: undefined,
|
||||
|
||||
init: function(){
|
||||
M.init()
|
||||
V.init()
|
||||
|
||||
init: function () {
|
||||
V.init();
|
||||
},
|
||||
arrowChangeLink: function() {
|
||||
C.windowOffset()
|
||||
if(C.windoOffset < (V.demarche.offsetTop - M.offsetLimit)) {
|
||||
V.arrowLinkToDemarche()
|
||||
}
|
||||
else if(C.windoOffset < (V.engagements.offsetTop - M.offsetLimit)) {
|
||||
V.arrowLinkToEngagements()
|
||||
}
|
||||
else if(C.windoOffset < (V.elevages.offsetTop - M.offsetLimit)) {
|
||||
V.arrowLinkToElevages()
|
||||
}
|
||||
else if(C.windoOffset < (V.data.offsetTop - M.offsetLimit)) {
|
||||
V.arrowLinkToData()
|
||||
}
|
||||
else if(C.windoOffset < (V.footer.offsetTop - M.offsetLimit)) {
|
||||
V.arrowLinkToFooter()
|
||||
}
|
||||
arrowChangeLink: function () {
|
||||
C.windowOffset();
|
||||
if (C.windoOffset < V.demarche.offsetTop - M.offsetLimit) {
|
||||
V.arrowLinkToDemarche();
|
||||
} else if (C.windoOffset < V.engagements.offsetTop - M.offsetLimit) {
|
||||
V.arrowLinkToEngagements();
|
||||
} else if (C.windoOffset < V.elevages.offsetTop - M.offsetLimit) {
|
||||
V.arrowLinkToElevages();
|
||||
} else if (C.windoOffset < V.data.offsetTop - M.offsetLimit) {
|
||||
V.arrowLinkToData();
|
||||
} else if (C.windoOffset < V.footer.offsetTop - M.offsetLimit) {
|
||||
V.arrowLinkToFooter();
|
||||
}
|
||||
},
|
||||
windowOffset: function() {
|
||||
C.windoOffset = M.getWindowOffset()
|
||||
windowOffset: function () {
|
||||
C.windoOffset = M.getWindowOffset();
|
||||
},
|
||||
checkLogoReduced: function() {
|
||||
C.windowOffset()
|
||||
if(C.windoOffset > 0) {
|
||||
V.navLogo.classList.add("imgReduced");
|
||||
V.navBg.classList.remove("background");
|
||||
V.navBg.classList.add("plain-background");
|
||||
}
|
||||
else{
|
||||
V.navLogo.classList.remove("imgReduced");
|
||||
V.navBg.classList.add("background");
|
||||
V.navBg.classList.remove("plain-background");
|
||||
}
|
||||
}
|
||||
},
|
||||
V = {
|
||||
checkLogoReduced: function () {
|
||||
C.windowOffset();
|
||||
if (C.windoOffset > 0) {
|
||||
V.navLogo.classList.add("imgReduced");
|
||||
V.navBg.classList.remove("background");
|
||||
V.navBg.classList.add("plain-background");
|
||||
} else {
|
||||
V.navLogo.classList.remove("imgReduced");
|
||||
V.navBg.classList.add("background");
|
||||
V.navBg.classList.remove("plain-background");
|
||||
}
|
||||
},
|
||||
}),
|
||||
(V = {
|
||||
arrow: undefined,
|
||||
arrowUp: undefined,
|
||||
arrowDown: undefined,
|
||||
|
|
@ -63,92 +54,92 @@ V = {
|
|||
footer: undefined,
|
||||
navLogo: undefined,
|
||||
|
||||
init: function() {
|
||||
V.selectors()
|
||||
V.bindEvent()
|
||||
C.arrowChangeLink()
|
||||
init: function () {
|
||||
V.selectors();
|
||||
V.bindEvent();
|
||||
C.arrowChangeLink();
|
||||
},
|
||||
selectors: function() {
|
||||
V.arrow = document.querySelectorAll(".arrow")
|
||||
V.arrowUp = document.querySelector(".arrowUp")
|
||||
V.arrowDown = document.querySelector(".arrowDown")
|
||||
V.home = document.querySelector("#home")
|
||||
V.demarche = document.querySelector("#demarche")
|
||||
V.engagements = document.querySelector("#engagements")
|
||||
V.elevages = document.querySelector("#elevages")
|
||||
V.data = document.querySelector("#data")
|
||||
V.footer = document.querySelector("#footer")
|
||||
V.navigation = document.querySelector("#navigation")
|
||||
V.navBg = document.querySelector("#navigation div")
|
||||
V.navLogo = document.querySelector("#navigation img")
|
||||
V.menu = document.querySelector("#navigation ul")
|
||||
V.menuBtnOpen = document.querySelector(".navbtOpen")
|
||||
V.menuBtnClose = document.querySelector(".navbtClose")
|
||||
V.menuActivated = document.querySelector("#navigation ul")
|
||||
V.menuTitle = document.querySelectorAll("#navigation ul li")
|
||||
V.footerMent = document.querySelector("#footer .mentions")
|
||||
V.footerPoli = document.querySelector("#footer .politique")
|
||||
V.openPopinPolitique = document.querySelector(".openPopinPolitique")
|
||||
selectors: function () {
|
||||
V.arrow = document.querySelectorAll(".arrow");
|
||||
V.arrowUp = document.querySelector(".arrowUp");
|
||||
V.arrowDown = document.querySelector(".arrowDown");
|
||||
V.home = document.querySelector("#home");
|
||||
V.demarche = document.querySelector("#demarche");
|
||||
V.engagements = document.querySelector("#engagements");
|
||||
V.elevages = document.querySelector("#elevages");
|
||||
V.data = document.querySelector("#data");
|
||||
V.footer = document.querySelector("#footer");
|
||||
V.navigation = document.querySelector("#navigation");
|
||||
V.navBg = document.querySelector("#navigation div");
|
||||
V.navLogo = document.querySelector("#navigation img");
|
||||
V.menu = document.querySelector("#navigation ul");
|
||||
V.menuBtnOpen = document.querySelector(".navbtOpen");
|
||||
V.menuBtnClose = document.querySelector(".navbtClose");
|
||||
V.menuActivated = document.querySelector("#navigation ul");
|
||||
V.menuTitle = document.querySelectorAll("#navigation ul li");
|
||||
V.footerMent = document.querySelector("#footer .mentions");
|
||||
V.footerPoli = document.querySelector("#footer .politique");
|
||||
V.openPopinPolitique = document.querySelector(".openPopinPolitique");
|
||||
},
|
||||
bindEvent: function() {
|
||||
for (let i = 0 ; i < V.arrow.length ; i ++) {
|
||||
V.arrow[i].addEventListener("click", C.arrowChangeLink)
|
||||
}
|
||||
window.addEventListener("scroll", C.checkLogoReduced)
|
||||
V.menuBtnOpen.addEventListener("click", V.menuOpen)
|
||||
V.menuBtnClose.addEventListener("click", V.menuClose)
|
||||
for (let i = 0 ; i < V.menuTitle.length ; i ++) {
|
||||
V.menuTitle[i].addEventListener("click", V.menuClose)
|
||||
}
|
||||
V.footerMent.addEventListener("click", V.popinMentions)
|
||||
V.footerPoli.addEventListener("click", V.popinPolitique)
|
||||
V.openPopinPolitique.addEventListener("click", V.popinPolitique)
|
||||
bindEvent: function () {
|
||||
for (let i = 0; i < V.arrow.length; i++) {
|
||||
V.arrow[i].addEventListener("click", C.arrowChangeLink);
|
||||
}
|
||||
window.addEventListener("scroll", C.checkLogoReduced);
|
||||
V.menuBtnOpen.addEventListener("click", V.menuOpen);
|
||||
V.menuBtnClose.addEventListener("click", V.menuClose);
|
||||
for (let i = 0; i < V.menuTitle.length; i++) {
|
||||
V.menuTitle[i].addEventListener("click", V.menuClose);
|
||||
}
|
||||
V.footerMent.addEventListener("click", V.popinMentions);
|
||||
V.footerPoli.addEventListener("click", V.popinPolitique);
|
||||
V.openPopinPolitique.addEventListener("click", V.popinPolitique);
|
||||
},
|
||||
popinMentions: function() {
|
||||
Swal.fire({
|
||||
template: '#popin-mention',
|
||||
showCloseButton: true,
|
||||
width: "100%",
|
||||
confirmButtonColor: 'var(--yellow)',
|
||||
})
|
||||
popinMentions: function () {
|
||||
Swal.fire({
|
||||
template: "#popin-mention",
|
||||
showCloseButton: true,
|
||||
width: "100%",
|
||||
confirmButtonColor: "var(--yellow)",
|
||||
});
|
||||
},
|
||||
popinPolitique: function() {
|
||||
Swal.fire({
|
||||
template: '#popin-politique',
|
||||
showCloseButton: true,
|
||||
width: "100%",
|
||||
confirmButtonColor: 'var(--yellow)',
|
||||
})
|
||||
popinPolitique: function () {
|
||||
Swal.fire({
|
||||
template: "#popin-politique",
|
||||
showCloseButton: true,
|
||||
width: "100%",
|
||||
confirmButtonColor: "var(--yellow)",
|
||||
});
|
||||
},
|
||||
menuOpen: function() {
|
||||
V.menu.classList.add("menuActivated")
|
||||
V.navLogo.classList.remove("imgReduced")
|
||||
V.menuBtnClose.classList.remove("vishidden")
|
||||
menuOpen: function () {
|
||||
V.menu.classList.add("menuActivated");
|
||||
V.navLogo.classList.remove("imgReduced");
|
||||
V.menuBtnClose.classList.remove("vishidden");
|
||||
},
|
||||
menuClose: function() {
|
||||
V.menuBtnClose.classList.add("vishidden")
|
||||
V.menu.classList.remove("menuActivated")
|
||||
V.navLogo.classList.remove("imgReduced")
|
||||
menuClose: function () {
|
||||
V.menuBtnClose.classList.add("vishidden");
|
||||
V.menu.classList.remove("menuActivated");
|
||||
V.navLogo.classList.remove("imgReduced");
|
||||
},
|
||||
arrowLinkToDemarche: function() {
|
||||
V.arrowUp.href = "#"
|
||||
V.arrowDown.href = "#demarche"
|
||||
arrowLinkToDemarche: function () {
|
||||
V.arrowUp.href = "#";
|
||||
V.arrowDown.href = "#demarche";
|
||||
},
|
||||
arrowLinkToEngagements: function() {
|
||||
V.arrowUp.href = "#"
|
||||
V.arrowDown.href = "#engagements"
|
||||
arrowLinkToEngagements: function () {
|
||||
V.arrowUp.href = "#";
|
||||
V.arrowDown.href = "#engagements";
|
||||
},
|
||||
arrowLinkToElevages: function() {
|
||||
V.arrowUp.href = "#demarche"
|
||||
V.arrowDown.href = "#elevages"
|
||||
arrowLinkToElevages: function () {
|
||||
V.arrowUp.href = "#demarche";
|
||||
V.arrowDown.href = "#elevages";
|
||||
},
|
||||
arrowLinkToData: function() {
|
||||
V.arrowUp.href = "#engagements"
|
||||
V.arrowDown.href = "#data"
|
||||
arrowLinkToData: function () {
|
||||
V.arrowUp.href = "#engagements";
|
||||
V.arrowDown.href = "#data";
|
||||
},
|
||||
arrowLinkToFooter: function() {
|
||||
V.arrowUp.href = "#elevages"
|
||||
V.arrowDown.href = "#footer"
|
||||
}
|
||||
}
|
||||
C.init();
|
||||
arrowLinkToFooter: function () {
|
||||
V.arrowUp.href = "#elevages";
|
||||
V.arrowDown.href = "#footer";
|
||||
},
|
||||
});
|
||||
C.init();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue