jquery prepend moving page

0

I have a div that contains several lists (uls) of a box, in each box has an image and a description. I'm implementing an infinite roll up as follows:

  • The user accesses a specific page (ex page 6), each page has 5 uls. Home
  • When the page is rolled up a new page is loaded by ajax, bringing in another 5 uls and being inserted into the html by a prepend. Home

Prior to loading, the first ul ul id 'ul30', after loading the first ul ul id 'ul25'.

When I prepend the page scrolls the screen to ul25. How can I keep the original position (ul30)?

* Note: I tried to make an animation using the $ (). animate () at the end of the ajax success for the ul30, but since the box has images, which take a while to load, the position passed to the animate still is not the final position (the browser is still mounting the page) so it is in a position between the ul25 and the ul30

* Obs2: I can not set a fixed size for images via css, even though they have a default size of registered images (these may have changed size later)

[EDIT]

For example the implementation I want to do is facebook, since it is in the timeline and new stories are loaded, the screen position is not changed, but an html content is inserted at the beginning of the timeline element.

    
asked by anonymous 23.02.2016 / 22:05

1 answer

0

Pilati, a simple solution for your case, is to jump to the current element.

var url = location.href;               //Armazene a URL sem o #
var topo = "ul30";                     //id do elemento que você quer exibir no topo
location.href = "#" + topo;            //Para mover o scroll para o elemento desejado.
history.replaceState(null,null,url);   //removendo o # da URL.
    
24.02.2016 / 14:21