Foros del Web » Programando para Internet » Javascript » Frameworks JS »

mover scroll automaticamente

Estas en el tema de mover scroll automaticamente en el foro de Frameworks JS en Foros del Web. Hola a todos, queria saber si alguien me puede orientar a hacer un script que mueva la pagina hacia arriba o hacia abajo, osea supongamos ...
  #1 (permalink)  
Antiguo 29/03/2011, 20:31
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
mover scroll automaticamente

Hola a todos, queria saber si alguien me puede orientar a hacer un script que mueva la pagina hacia arriba o hacia abajo, osea supongamos que tengo un menu en la parte superior y hago click en alguno de ellos, quiero que baje hacia el titulo que yo quiera pero con efecto easing o nose como se escirbe .. saludos y gracias a aquel//lla que me logre ayudar..!!
  #2 (permalink)  
Antiguo 30/03/2011, 06:44
Avatar de Naahuel  
Fecha de Ingreso: marzo-2011
Ubicación: localhost
Mensajes: 796
Antigüedad: 13 años, 1 mes
Puntos: 192
Respuesta: mover scroll automaticamente

¿Vos decís usando anclas? Yo suelo usar este script:
http://css-tricks.com/snippets/jquery/smooth-scrolling/

Fijate en el demo. Saludos
__________________
nahueljose.com.ar
  #3 (permalink)  
Antiguo 30/03/2011, 11:24
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
Respuesta: mover scroll automaticamente

Cita:
Iniciado por Naahuel Ver Mensaje
¿Vos decís usando anclas? Yo suelo usar este script:
http://css-tricks.com/snippets/jquery/smooth-scrolling/

Fijate en el demo. Saludos
hola, donde remplazo los id de los enlaces en el script ?}


$(document).ready(function() {
function filterPath(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
}
var locationPath = filterPath(location.pathname);
var scrollElem = scrollableElement('html', 'body');

$('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
location.hash = target;
});
});
}
}
});

// use the first element that is "scrollable"
function scrollableElement(els) {
for (var i = 0, argLength = arguments.length; i <argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop()> 0) {
return el;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop()> 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return el;
}
}
}
return [];
}

});
  #4 (permalink)  
Antiguo 30/03/2011, 17:18
Avatar de Naahuel  
Fecha de Ingreso: marzo-2011
Ubicación: localhost
Mensajes: 796
Antigüedad: 13 años, 1 mes
Puntos: 192
Respuesta: mover scroll automaticamente

En ningún lado. Si tu sitio funciona con anclas (estilo Wikipedia, que cuando hacés click en algún lado te lleva a otra sección dentro de la misma página) ese escript hará que la transición sea suave. No necesitás agregar nada, sólo incrustalo al script después de jQuery.
__________________
nahueljose.com.ar
  #5 (permalink)  
Antiguo 23/04/2011, 18:19
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
Respuesta: mover scroll automaticamente

Hola a todos, queria saber como hacer ese ejemplo con anclas pero para cuando se cargue la pagina en vez de usar el evento "onClick", solo quiero que cuando se reciba una variable a travez de la url (php) quiero que que se mueva el scroll hacia cierto lugar...

saludos!!!

Etiquetas: jquery
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:28.