Lo que necesito:
Cómo hacerlo con una tecla está bien, pero es preferible con el mouse. Necesito que el sitio web se desplace por sí mismo mientras el mouse o la tecla están presionados, y una vez liberado, el sitio vuelve a la parte superior. pero si llega a la sección Final, la tecla/mouse hacia abajo ya no funcionará.
Lo que tengo:
Entonces, el sitio está usando gsap y scrolltriggers. Tengo opacidad táctil:
HTML:
<a href="#top" class="touchableOpacity" id="TO"></a>JS:
$("a[href='#top']").mouseup(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); tls8In .to("#TO",{top: -2000, duration:0.1})Se lleva a la parte superior con el mouse hacia arriba y se elimina de la ventana gráfica cuando se ingresa a la sección final. '''
¡Hola! Prueba este código de arriba. Este código agrega funcionalidad para desplazar la etiqueta html al elemento, cuya identificación se establece en el atributo href .
$('a[href*=#]:not([href=#])').click(function () { if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) { let target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ // which elements should be scrolled scrollTop: target.offset().top }, 1000); // animation time return false; } } });