使用jQuery进行选择,然后使用YUI进行动画?好主意吗?

发布于 2024-09-07 22:02:00 字数 569 浏览 1 评论 0原文

jQuery 的动画引擎对我来说效果不佳。它没有内置的缓动和彩色动画,而且我使用的插件不能一致地正常工作。

我过去对 YUI 的动画引擎有很好的经验。是否可以使用 jQuery 选择项目,然后使用 YUI 为它们设置动画?下面是我当前的 jQuery 动画代码,用于在单击 div 时为其设置动画:

$("div.article").mousedown(function() {
    $(this).children(".box").animate({height:'+=100px', paddingTop: '24px'},300);   
    $(this).children(".box").children(".subBoxA").show().animate({opacity: "1"}, 500);  
});

How would I go about Converting the Animations in this function to YUI3?

(这是个好主意吗?我应该将所有东西都转换为 YUI3、选择器等等吗?另外,如果这是一个愚蠢的问题,请原谅我,我是个菜鸟)

jQuery's animation engine isn't working well for me. It doesn't have easing and color animation built-in, and the plugins I am using for them don't work properly together consistently.

I've had good experience with YUI's animation engine in the past. Is it possible to use jQuery to select items, and then use YUI to animate them? Here's my current jQuery-animated code to animate a div when you click it:

$("div.article").mousedown(function() {
    $(this).children(".box").animate({height:'+=100px', paddingTop: '24px'},300);   
    $(this).children(".box").children(".subBoxA").show().animate({opacity: "1"}, 500);  
});

How would I go about converting the animations in this function to YUI3?

(Is this even a good idea? Should I just convert everything to YUI3, selectors and all? Also, if this comes across as a dumb question, forgive me, i'm a noob)

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

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

发布评论

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

评论(2

や莫失莫忘 2024-09-14 22:02:00

这些 JavaScript 库的部分好处是您可以用更少的代码获得大量的功能。通过包含 JQuery 和 YUI,您可以快速增加页面的大小。

如果您使用 jquery 的唯一目的是选择 DOM 中的元素,那么一定要转换为 YUI,因为它有许多相同的选择方法。如果您同时使用 jquery 和 YUI 的多个部分,那么混合它们可能是您目前必须忍受的事情。

Part of the benefit of these javascript libraries is that you get a ton of functionality in a smaller amount of code. By including both JQuery and YUI, you are quickly increasing the size of your pages.

If the only thing you are using jquery for is to select elements in the DOM, then definitely convert to YUI as it has many of the same selection methods. If you are using several pieces of both jquery and YUI, then mixing them may be something you have to live with for now.

猫九 2024-09-14 22:02:00

如果您要对单个元素进行动画处理,则可以执行以下操作:

YUI.use("anim", function (Y) {
    $("div.article").mousedown(function () {
        var el = $(this).children(".box")[0],
            anim;
        anim = new Y.Anim({
            node: el,
            /* animation configuration */
        });
        anim.run();
    });
});

据我所知,YUI 不支持开箱即用的对多个元素进行动画处理,尽管您可以使用补间事件来实现它。

不过,我怀疑您最好使用 jQuery UI 。它提供彩色动画和高级缓动。

If you are animating a single element, you can do something like this:

YUI.use("anim", function (Y) {
    $("div.article").mousedown(function () {
        var el = $(this).children(".box")[0],
            anim;
        anim = new Y.Anim({
            node: el,
            /* animation configuration */
        });
        anim.run();
    });
});

AFAIK, YUI does not support animating multiple elements out of the box, though you could implement it using the tween events.

I suspect you are better off using jQuery UI, however. It provides color animation and advanced easing.

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