PDA

View Full Version : How Do You Animate Adding Panel to Viewport?



ccocco_dw
11 Jan 2011, 4:05 AM
Hi, how would I animate (e.g. Slide In/Slide Out) adding a panel to the viewport? The showcase demonstrates a sliding panel that already exists within a container using a button to trigger it, but in my case, I'm creating a new container panel, adding it to the viewport dynamically. Would I have to override the setVisible() method for the new container and call el().slideIn(Direction.LEFT, FxConfig.NONE)? Thanks!

Ersmarker
14 Jan 2011, 4:53 AM
Try this small example.


ContentPanel cp;
Viewport vp;
public void onModuleLoad() {
vp = new Viewport();

Button button = new Button("Click me");
button.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
cp = new ContentPanel();
cp.setSize(100, 100);
vp.add(cp);
vp.layout();
cp.el().slideIn(Direction.LEFT,FxConfig.NONE);
}
});
vp.add(button);
RootPanel.get().add(vp);
}

You should be aware the gxt layout engine is not aware of any animations and so further layouts could fail.