Desplácese sincrónicamente con slideDown

The slideDown applied to a div does the slideDown but doesn't scroll the page down and the div slided down div remains hidden from view. Is there a way to scroll the page down synchronously with slideDown so this div will be visible entirely?

$('#log').append('<div id="in_log">...</div>');


preguntado el 08 de noviembre de 11 a las 12:11

2 Respuestas

slideDown does not scroll the page automatically down. Also, you cannot scroll the page synchronously with the slideDown as you cannot determine the final height of the division. What you can do is to scroll the page using .animate() after the slideDown animation is completed

respondido 08 nov., 11:16

Well, is there even any way to do so as I want by the using jQuery? - Don Tomate

Yes, let the division scrollDown, and AFTER it finishes, scroll down the page using .animate() - John

Why not? If '#in_log' has a fixed height + some defined margin/padding (put it on the element instead of css to use it dynamically) you could calculate the to-be height. After that it's just 2 parallel calls. - Geert-Jan

you could scroll to the top of the div by doing:

var top = $('#in_log').offset().top

respondido 08 nov., 11:16

yes, but in your solution at-first we slideDown this div and only AFTER this we can start scrolling. But I want that these two processes occur at the same time :-) - Don Tomate

@cockroach-eater slideDown doesn't change the offset().top.. the height will become larger, but the top is still the same. - Manuel van Rijn

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.