Callback for jquery plugin Isotope

前端 未结 5 571
执念已碎
执念已碎 2021-02-09 05:48


I\'m using isotope ( http://isotope.metafizzy.co ) with expandable items, and i would like to use ScrollTo so that i can automatically scroll to the newly expanded item..

5条回答
  •  一个人的身影
    2021-02-09 06:12

    allright,

    sneaking in the isotope code, i found that the animation options are passed directly to the animate jquery method, so i added the complete callback to these options:

    animationOptions: {
        duration: 4000,
        easing: 'easeInOutQuad',
        queue: false,
        complete: iwannascroll
    }
    

    then i was able to filter my expanded object and scroll to it :

                function iwannascroll(){
                    var target = $(this);
                    if (target.hasClass('expanded'))
                        $.scrollTo(target, 800);                
                }
    

    obviously it will work only if you use the jQuery animate method for the animation.. If anyone knows a better and "universal" way, i would love to hear it ;)

提交回复
热议问题