使用 Galleriffic 2.0 建立动画队列

发布于 2024-10-12 05:37:38 字数 260 浏览 1 评论 0原文

我试图弄清楚如何使用 stop() 函数来停止 Galleriffic 发生的动画构建。当您快速且重复地将鼠标悬停在缩略图上时,就会发生这种情况。我知道在一个简单的 jquery 脚本中,您可以将 stop() 函数与 animate 函数一起使用,但是 galleriffic 使用了太多代码,我不确定在哪里以及如何应用它。

顺便说一句,我是 jquery 新手。使用 jQuery 1.4.4 和 Galleriffic 2.0,并一直在研究 Galleriffic 下载中包含的示例。

I'm trying to figure out how to use the stop() function to stop the animation buildup that occurs with Galleriffic. It happens when you mouse over the thumbnail images quickly and repetitively. I know in a simple jquery script you'd use the stop() function with the animate function, but galleriffic uses so much code I'm not exactly sure where and how to apply it.

I'm new to jquery btw. Using jQuery 1.4.4 and Galleriffic 2.0, and have been working off the examples included with the Galleriffic download.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤君无依 2024-10-19 05:37:38

好吧,终于想通了。事实证明,当鼠标悬停在缩略图上时透明度逐渐消失是由名为“jquery.opacityrollover.js”的脚本处理的。

透明度不是使用 jquery“animate”函数进行动画处理,而是使用“fadeTo”函数进行动画处理。代码如下所示:

/**
 * jQuery Opacity Rollover plugin
 *
 * Copyright (c) 2009 Trent Foley (http://trentacular.com)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
;(function($) {
var defaults = {
    mouseOutOpacity:   0.67,
    mouseOverOpacity:  1.0,
    fadeSpeed:         'fast',
    exemptionSelector: '.selected'
};

$.fn.opacityrollover = function(settings) {
    // Initialize the effect
    $.extend(this, defaults, settings);

    var config = this;

    function fadeTo(element, opacity) {
        var $target = $(element);

        if (config.exemptionSelector)
            $target = $target.not(config.exemptionSelector);    

        $target.fadeTo(config.fadeSpeed, opacity);
    }

    this.css('opacity', this.mouseOutOpacity)
        .hover(
            function () {
                fadeTo(this, config.mouseOverOpacity);
            },
            function () {
                fadeTo(this, config.mouseOutOpacity);
            });

    return this;
};
})(jQuery);

所以我通过试验和测试发现你所要做的就是更改

$target.fadeTo(config.fadeSpeed, opacity);

$target.stop().fadeTo(config.fadeSpeed, opacity);

Okay, finally figured it out. Turns out that the transparency fading when mousing over the thumbnails is handled by a script called "jquery.opacityrollover.js".

The transparency is not animated with the jquery "animate" function, but is instead animated with the "fadeTo" function. The code looks like this:

/**
 * jQuery Opacity Rollover plugin
 *
 * Copyright (c) 2009 Trent Foley (http://trentacular.com)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
;(function($) {
var defaults = {
    mouseOutOpacity:   0.67,
    mouseOverOpacity:  1.0,
    fadeSpeed:         'fast',
    exemptionSelector: '.selected'
};

$.fn.opacityrollover = function(settings) {
    // Initialize the effect
    $.extend(this, defaults, settings);

    var config = this;

    function fadeTo(element, opacity) {
        var $target = $(element);

        if (config.exemptionSelector)
            $target = $target.not(config.exemptionSelector);    

        $target.fadeTo(config.fadeSpeed, opacity);
    }

    this.css('opacity', this.mouseOutOpacity)
        .hover(
            function () {
                fadeTo(this, config.mouseOverOpacity);
            },
            function () {
                fadeTo(this, config.mouseOutOpacity);
            });

    return this;
};
})(jQuery);

So I figured out through trial and testing that all you have to do is change

$target.fadeTo(config.fadeSpeed, opacity);

to

$target.stop().fadeTo(config.fadeSpeed, opacity);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文