代码之家  ›  专栏  ›  技术社区  ›  Sergey Miryanov

如何在Qooxdoo“摇”一扇窗?

  •  2
  • Sergey Miryanov  · 技术社区  · 16 年前

    我想摇一下窗户,但控制台出错了。我的代码:

      var win = new qx.ui.window.Window ("Login");
      win.setLayout (new qx.ui.layout.Grow);
      win.add (view);
    
      this.effect = new qx.fx.effect.combination.Shake (
        win.getContainerElement ().getDomElement ());
    
      return win;
    

    其中view是一个groupbox实例(来自demobrowser/animation/login)。

    3 回复  |  直到 15 年前
        1
  •  3
  •   Jonathan Weiss    16 年前

    正如您自己发现的:在创建shake对象时,窗口的dom元素不在那里。在qooxdoo中,我们一次创建所有的dom元素,这样浏览器就不必渲染得比需要的更频繁。

    在窗口触发“appear”事件时(您也可以使用“resize”事件),dom元素已经创建。请确保使用addListenerOnce()而不是addListener()!否则,如果窗口已隐藏,则每次窗口再次可见时,都将创建新的震动效果。;-)

        2
  •  3
  •   Sergey Miryanov    16 年前

    对不起,有噪音! 如果我在“出现”监听器中创建了一个效果,那么代码可以很好地工作。

        win.addListener ("appear", function (e) 
        {
          this.effect = new qx.fx.effect.combination.Shake (
            win.getContainerElement ().getDomElement ());
        }, this);
    
        3
  •  0
  •   Igor Popov    15 年前
    var win = new qx.ui.window.Window("Login");
    win.setLayout(new qx.ui.layout.Grow);
    win.add(view);
    win.addListener("appear", function(){
      var effect = new qx.fx.effect.combination.Shake(win.getContainerElement().getDomElement());
      effect.start();
    }, this);
    return win;
    
    推荐文章