gwt使用jquery效果可能吗? [英] gwt using jquery effect possible?

查看:130
本文介绍了gwt使用jquery效果可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的gwt中,我有一个像下面一样的按钮来创建新的窗口小部件

  @UiHandler(buttonfire) 
void addNewWidget(ClickEvent event){


htmlPanelHolder.add(new MyCustomWidget(),placeholder);


如何使用jquery使MyCustomWidget()显示在屏幕上它使用jqueryfadein效果

我已经尝试过将jsni调用到新的MyCustomWidget()onload()中,但不起作用。可以指导我吗?

解决方案

也可以在不使用jQuery的情况下创建淡入淡出效果。如果你想这样做,只需编写一个这样的Animation类:

  public class FadeInAnimation extends Animation {
private最终的UIObject uiObject;

FadeInAnimation(最终的UIObject uiObject){
this.uiObject = uiObject;
}

@Override
protected void onUpdate(final double progress){
uiObject.getElement()。getStyle()。setOpacity(progress);


然后你可以在任何部件上使用它: p>

  new FadeInAnimation(myWidget).run(5000); 

注意:调用 getStyle() .setOpacity(..)甚至可以处理特殊情况IE6 / 7,它设置 style.filter ='alpha(opacity ='+(value * 100)+ ')';


in my gwt, i have a button that fire like below to create new widget

 @UiHandler("buttonfire")
  void addNewWidget(ClickEvent event) {


     htmlPanelHolder.add(new MyCustomWidget(),"placeholder");

 }

how to use jquery so that when the MyCustomWidget() show on screen it is using jquery "fadein" effect

i already tried putting jsni to call jquery inside new MyCustomWidget() onload() but doesnt work. can guide me on this?

解决方案

It's also possible to create a fade in effect without using jQuery. If you want to do that, just write an Animation class like this:

public class FadeInAnimation extends Animation {
    private final UIObject uiObject;

    FadeInAnimation(final UIObject uiObject) {
      this.uiObject = uiObject;
    }

    @Override
    protected void onUpdate(final double progress) {
      uiObject.getElement().getStyle().setOpacity(progress);
    }
}

Then you can use it on any widget:

new FadeInAnimation(myWidget).run(5000);

Note: The call to getStyle().setOpacity(..) even takes care of the special case IE6/7, where it sets style.filter = 'alpha(opacity=' + (value * 100) + ')';

这篇关于gwt使用jquery效果可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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