Refresher opens so much Threads

Hi , on Refresher addon , there is some sample that opens threads per request.
Its not good solution.

I want to make some animation.
For timed animation effects , we need to open refresher ?

It really sucks if we need to open thread per timed animations :S

For example , every 10 seconds 1 panel fade and other opens back.
I didnt see any solution for this?

Hi,

You might not want to animate with Refresher, instead try something like
Animator
.

…and if you still use Refresher for animation, I’d suggest you don’t start new threads at all - you only need threads to do background work on the server side.

Best Regards,
Marc

My problem is i need to make animations in time.
I wont do 1 animation , I’ll do series of animation.
Fading 1 panel to other in time.

    final Window window = new Window("Vaadin Portlet Application");
    setMainWindow(window);
    
    final UserData data = (UserData) getUser();
    final ThemeDisplay themeDisplay = data.themeDisplay;
    
    
    final AnimatorProxy anim = new AnimatorProxy( );
    window.addComponent(anim);
    
    
    final Panel panel_pvp = new Panel ();
    final Panel  panel_pk = new Panel ();
    final Panel panel_castle = new Panel ();
    
    
    AbsoluteLayout layout = new AbsoluteLayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    
    
    layout.addComponent(panel_pvp, "left:0;top:0;width:100%;height:100%;z-index:0;");
    layout.addComponent(panel_pk, "left:0;top:0;width:100%;height:100%;z-index:1;");
    layout.addComponent(panel_castle, "left:0;top:0;width:100%;height:100%;z-index:2;");
    



    //1.
    anim.animate(panel_pvp, AnimType.FADE_IN).setDuration(3000).setDelay(1000);
    anim.animate(panel_pk, AnimType.FADE_OUT).setDuration(3000).setDelay(1000);
    anim.animate( panel_castle, AnimType.FADE_OUT).setDuration(3000).setDelay(1000);

But how can i make this as a loop ? this only effecting 1 time.
I need to handle when animation finish maybe?
I will show
1-) panel_pvp
After 3 seconds
2-) panel_pk
After 3 seconds
3-) panel_castle
After 3 seconds , will goto 1 back.

How can i do series of loop animation like this?

Right.

I’m not too familiar with Animator, but apparently it does not have a onAnimationFinished event - if it did, you’d obviously re-start the animation there.

I guess you could do that task with Refresher, just don’t start a new thread for each iteration - just re-start the animation each time.

public void refresh(final Refresher source) {
      // just animate, no threads:
     startAnimation();
}

If you get timing issues, keep a timestamp on the server side so you know when you’re supposed to re-start the animation.

long time = 0;
public void refresh(final Refresher source) {
      long now = new Date().getTime();
      if (now-time>limit) {
        startAnimation();
        time = now;
     }
}

How does that sound?

// Marc

As i read , everytime refresher sending server command.
Why there is no keyframe client based animation solution on vaadin?
it would be great.

If you want to do sequential animations, you should use AnimatorProxy. You can add an AnimationListener which is fired when an animation is finished. Check the AnimatorApplication for examples.

Well , some problem for me is , everytime sending json to server for animation seems not good idea.
That even ProxyAnimation is sending packet everytime to server when its finishing its animation…

Ok so if I understood correctly, you want to create animations that would run sequentially on the client-side, without any server-communication? I think the Animator can’t handle those cases yet. You could try using e.g. jQuery with a CustomLayout or embedding Vaadin in your own HTML page. See for example
this thread
.

true ,
1+ thing is

AnimatorProxy seems buggy , when i apply

    anim.animate(panelz[0]

, AnimType.FADE_OUT).setDuration(3000).setDelay(500);
anim.animate(panelz[0]
, AnimType.FADE_IN).setDuration(3000).setDelay(500);

both of these animation doing fade out animation.No fade in animation…
It should be fixed.I ve downloaded latest version of vaadin and i got this problem