Open mistyn8 opened 7 years ago
/**
* animate to top
* @param {*} context
* @param {Array.<jQuery.fn.jplist.StatusDTO>} statuses
*/
var animateToTop = function(context, statuses){
var offset
,shouldAnimate = false;
if(statuses){
for(var i=0; i<statuses.length; i++){
if(statuses[i].isAnimateToTop){
shouldAnimate = true;
break;
}
}
if(shouldAnimate){
//set offset
offset = jQuery(context.options.animateToTop).offset().top;
jQuery('html, body').animate({
scrollTop: offset
}, context.options.animateToTopDuration);
}
}
};
updated
if(statuses[i].isAnimateToTop){
to
if (statuses[i].isAnimateToTop && context.history.listStatusesQueue.length > 1) {
seems to do the trick
if the jplist pagination plugin affects content that is below the fold, eg outside of the viewport then the page will auto scroll on load if animate-to-top is true.
really we want the page to load, stay top 0px and animate-to-top only occurs if the user interacts with the pagination say..
I can't see an easy way to see that the status is the initiation event and not a subsequent user interaction to allow for this.