带有缓动和回调函数的scrollTo [英] scrollTo with easing and a callback function

查看:437
本文介绍了带有缓动和回调函数的scrollTo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,这是我的代码:

Here is my code thus far:

    $('.my_button').click(function() {

        $.scrollTo( '#my_anchor', 1200, {easing:'easeInOutExpo'}, function() {          

            // function not working here

        });

    });

回调函数以前可以工作,但是由于我使用了缓动方式更改为scrollTo方法,因此不再可用了!

The callback function worked previously, but since I changed to the scrollTo method with easing, it doesn't any more!

为了明确起见,我只需要知道如何使我的回调函数再次工作,其他一切都很好.

Just to make it clear I only need to know how to get my callback function working again, everything else is fine.

推荐答案

没有第四个参数,但是第三个参数(设置)接受onAfter回调

There is no forth parameter, but the third parameter (settings) accepts an onAfter callback

$.scrollTo( '#my_anchor', 1200, {easing:'easeInOutExpo', onAfter: function() { }});

从源代码上进行设置:

 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
 *   @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *   @option {Number} duration The OVERALL length of the animation.
 *   @option {String} easing The easing method for the animation.
 *   @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *   @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
 *   @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
 *   @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *   @option {Function} onAfter Function to be called after the scrolling ends.
 *   @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.

这篇关于带有缓动和回调函数的scrollTo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆