将 mootools 脚本与 gwt 应用程序结合使用

发布于 2024-12-02 03:14:20 字数 2220 浏览 0 评论 0原文

我的问题是在 Composite 上制作一个动画,该动画在加载数据时启动。 我使用 html 在普通 div 上制作了动画以进行测试:

<div class="LoadDataWidget">
    <div id="arrow" class="greenArrow"></div>
</div>


.LoadDataWidget {
    width: 995px;
    height: 591px;
    background-image: url('images/ladowanie-danych.png');
    background-repeat: no-repeat;
    position: relative;
    margin: 0px auto;
    visibility: hidden;
}

.LoadDataWidget .greenArrow {
    width: 102px;
    height: 141px;
    background-image: url('images/ladowanie-danych-strzalka.png');
    background-position: bottom;
    background-repeat: no-repeat;
    position: absolute;
    left: 500px;
    top: 205px;
}

JavaScript+mootools 动画脚本:

    window.addEvent('domready', function(){

        var effect = new Fx.Tween('arrow', {duration: 800}),periodical;

        // Create the function wich will run the effect
        var fx = function() {
            effect.start('height', '141').chain(function(){
                effect.start('height', '161');
            });
            // return this function, so you could do fx() which returns fx,
            //or fx()()() which still returns fx and runs the function 3 times
            return fx;
        };

        fx().periodical(1700);

        // assing 'singleImage' variable to the image tag with the 'image' ID
        var singleImage = $$('.LoadDataWidget');

        // set a bunch of CSS styles to the aforementioned image
        singleImage.set('styles', {
            'opacity': 0,
            'visibility': 'visible'
        });

        // fade in the image
        singleImage.fade('in');


});

它有效。 这是一个从上到下的箭头动画。

但是,当我尝试在 gwt 应用程序中使用此脚本以及具有类“LoadDataWidget”和 id“arrow”的元素时,它不起作用。

还有我尝试制作动画的 GWT Composit 的 Java 代码:

import com.google.gwt.user.client.ui.SimplePanel;

public class LoadDataWidget extends SimplePanel {

    public LoadDataWidget() {
        setStyleName("LoadDataWidget");
        SimplePanel arrow = new SimplePanel();
        arrow.setStyleName("greenArrow");
        arrow.getElement().setId("arrow");
        setWidget(arrow);
    }
}

Domready 事件有问题吗?您有解决这个问题的任何线索吗?

My problem is make an animation on Composite which is started when data is loading.
I made animation on normal divs for tests using html:

<div class="LoadDataWidget">
    <div id="arrow" class="greenArrow"></div>
</div>


.LoadDataWidget {
    width: 995px;
    height: 591px;
    background-image: url('images/ladowanie-danych.png');
    background-repeat: no-repeat;
    position: relative;
    margin: 0px auto;
    visibility: hidden;
}

.LoadDataWidget .greenArrow {
    width: 102px;
    height: 141px;
    background-image: url('images/ladowanie-danych-strzalka.png');
    background-position: bottom;
    background-repeat: no-repeat;
    position: absolute;
    left: 500px;
    top: 205px;
}

JavaScript+mootools animation script:

    window.addEvent('domready', function(){

        var effect = new Fx.Tween('arrow', {duration: 800}),periodical;

        // Create the function wich will run the effect
        var fx = function() {
            effect.start('height', '141').chain(function(){
                effect.start('height', '161');
            });
            // return this function, so you could do fx() which returns fx,
            //or fx()()() which still returns fx and runs the function 3 times
            return fx;
        };

        fx().periodical(1700);

        // assing 'singleImage' variable to the image tag with the 'image' ID
        var singleImage = $('.LoadDataWidget');

        // set a bunch of CSS styles to the aforementioned image
        singleImage.set('styles', {
            'opacity': 0,
            'visibility': 'visible'
        });

        // fade in the image
        singleImage.fade('in');


});

It works.
It is an animation of arrow from top to bottom.

But when i try to use this script in gwt application with elements which have class "LoadDataWidget" and id "arrow" it doesn't work.

And there is Java code of GWT Composit which I try to animate:

import com.google.gwt.user.client.ui.SimplePanel;

public class LoadDataWidget extends SimplePanel {

    public LoadDataWidget() {
        setStyleName("LoadDataWidget");
        SimplePanel arrow = new SimplePanel();
        arrow.setStyleName("greenArrow");
        arrow.getElement().setId("arrow");
        setWidget(arrow);
    }
}

Is there problem with domready event? Have you got any clue for solve this problem?

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

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

发布评论

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

评论(1

花之痕靓丽 2024-12-09 03:14:20

您的 domready 事件在 html 加载且 DOM 准备就绪之后、GWT 加载并执行之前触发。

尝试在加载 GWT 后通过 JSNI 调用您的函数。

Your domready event triggers after html is loaded and DOM is ready, but before GWT is loaded and executed.

Try calling your function via JSNI after GWT is loaded.

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