fix: infinity
This commit is contained in:
parent
1ee4878530
commit
6837a638d4
9
main.js
9
main.js
@ -580,17 +580,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
counters.forEach(counter => observer.observe(counter));
|
||||
});
|
||||
|
||||
|
||||
// i know it is a bad code but it works 😅
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const track = document.querySelector(".move-slider-animation-box");
|
||||
const container = document.querySelector(".container");
|
||||
let speed = 1;
|
||||
let pos = 0;
|
||||
const normalSpeed = 1;
|
||||
let speed = 20;
|
||||
|
||||
function animate() {
|
||||
pos -= speed;
|
||||
track.style.transform = `translateX(${pos}px)`;
|
||||
|
||||
if (pos <= -100 && speed !== normalSpeed) {
|
||||
speed = normalSpeed;
|
||||
}
|
||||
|
||||
const firstChild = track.firstElementChild;
|
||||
const firstRect = firstChild.getBoundingClientRect();
|
||||
const containerRect = container.getBoundingClientRect();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user