Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
Copie el cuerpo al desplazarse hasta la parte inferior de la página (desplazamiento en bucle)

Estoy tratando de hacer un efecto de desplazamiento en bucle y funciona bastante bien en el escritorio, pero tiene un poco de errores en el móvil.

Enlace a la demostración: http://create-to-regenerate.com/create-to-regenerate-site/

Código:

 var doc = window.document, context = doc.querySelector('.loop'), items = doc.querySelectorAll('.loopItem'), clones = [], disableScroll = false, scrollHeight = 0, scrollPos = 0, clonesHeight = 0 function getScrollPos () { return (context.pageYOffset || context.scrollTop) - (context.clientTop || 0) } function setScrollPos (pos) { context.scrollTop = pos } function getClonesHeight () { clonesHeight = 0 Array.from(clones, clone => { clonesHeight = clonesHeight + clone.offsetHeight }) return clonesHeight } function reCalc () { scrollPos = getScrollPos() scrollHeight = context.scrollHeight clonesHeight = getClonesHeight() if (scrollPos <= 0) { setScrollPos(1) // Scroll 1 pixel to allow upwards scrolling } } function scrollUpdate () { if (!disableScroll) { scrollPos = getScrollPos() if (clonesHeight + scrollPos >= scrollHeight) { // Scroll to the top when you've reached the bottom setScrollPos(1) // Scroll down 1 pixel to allow upwards scrolling disableScroll = true } else if (scrollPos <= 0) { // Scroll to the bottom when you reach the top setScrollPos(scrollHeight - clonesHeight) disableScroll = true } } if (disableScroll) { // Disable scroll-jumping for a short time to avoid flickering window.setTimeout(function () { disableScroll = false }, 10) } } function onLoad () { Array.from(items, item => { const clone = item.cloneNode(true) context.appendChild(clone) clone.classList.add('js-clone') }) clones = context.querySelectorAll('.js-clone') reCalc() context.addEventListener('scroll', function () { window.requestAnimationFrame(scrollUpdate) }, false) window.addEventListener('resize', function () { window.requestAnimationFrame(reCalc) }, false) } window.onload = onLoad

En este sitio: https://diplomats.tv/ , el contenido simplemente se agrega al cuerpo cuando se desplaza hacia abajo, y esta podría ser una solución para obtener el mismo efecto en dispositivos móviles, pero no estoy seguro de cómo lograrlo. ¿este efecto? Gracias :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!