jplist icon indicating copy to clipboard operation
jplist copied to clipboard

Animate-to-top fires on plugin initialisation should only fire on first interaction with the controls?

Open mistyn8 opened this issue 8 years ago • 1 comments

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.

mistyn8 avatar Mar 22 '17 16:03 mistyn8

    /**
     * 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

mistyn8 avatar Mar 28 '17 11:03 mistyn8