Add js
This commit is contained in:
parent
9538f5713e
commit
480e837f29
1 changed files with 20 additions and 0 deletions
20
public/scroll_depth.js
Normal file
20
public/scroll_depth.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
let depthReached = 0;
|
||||
|
||||
window.addEventListener('scroll', function() {
|
||||
let s = window.scrollY,
|
||||
d = document.documentElement.scrollHeight,
|
||||
c = window.innerHeight,
|
||||
scrollPercent = (s / (d - c)) * 100;
|
||||
|
||||
if (scrollPercent > depthReached) {
|
||||
depthReached = scrollPercent;
|
||||
}
|
||||
|
||||
if (depthReached > 50 && depthReached < 55) {
|
||||
console.log("Der Benutzer hat 50% der Seite erreicht");
|
||||
} else if (depthReached > 80 && depthReached < 85) {
|
||||
console.log("Der Benutzer hat 80% der Seite erreicht");
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue