Saturday, 19 March 2016

jquery - How to scroll to top of the first post loaded with Ajax Pagination and Infinite Scroll plugin by Malinky?

I'm using Ajax Pagination and Infinite Scroll plugin by Malinky inside the WordPress blog that I'm currently working on. Plugin is set to load more button paging type.
I need to set it so that after the load more button is clicked, the first new loaded post is scrolled to the top of the viewport.
Unfortunately, the plugin is not very well documented and I can't find a way to select the first loaded post in order to apply animation to it inside the callback.

I've tried adding class 'anchor' to the last post both inside and outside the callback with $('article').last().addClass('anchor');and then doing $('html, body').animate to the $('article.anchor:nth-last-of-type(2)')inside the callback in order to scroll to the bottom of the second last .anchor element, which is the element after which the first new loaded post is positioned, but for some reason the animation seems to not work with any nth- pseudo class. It only works with last-of-type, which is useless to me.
Is there a way to make this work somehow?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...