I would really like to use the addon, but i am getting a weird problem.
I have a verticallayout that i am trying to animate. The verticallayout is centered within a FlexLayout component. When i run the application, the verticallayout is not animated at the center, but towards the lower right corner of the screen. It seems it does the animation and then applies “transform: translate(-50%, -50%)”. Any idea what’s happening here?
So just add the flex-container class to your FlexLayout and it should look fine (and do the animations at the correct place): layout.addClassName("flex-container");
I uploaded the testcode i was using to github. Find project [here]
(https://github.com/yusufnazir/testcases).
I used EntranceEffect.bounceIn on the verticallayout.
public class LoginView extends FlexLayout implements RouterLayout {
public LoginView() {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.addClassName("login-form");
add(verticalLayout);
Label welcomeLbl = new Label();
welcomeLbl.setWidth("100%");
welcomeLbl.setText("Welcome to!");
verticalLayout.add(welcomeLbl);
TextField usernameFld = new TextField();
usernameFld.setWidth("100%");
usernameFld.setLabel("Username");
usernameFld.setPlaceholder("Username");
verticalLayout.add(usernameFld);
PasswordField passwordField = new PasswordField();
passwordField.setWidth("100%");
passwordField.setLabel("Password");
passwordField.setPlaceholder("Password");
verticalLayout.add(passwordField);
Button submitFld = new Button();
submitFld.setClassName("login-submit-btn");
submitFld.setWidth("100%");
submitFld.setText("Log In");
verticalLayout.add(submitFld);
verticalLayout.setHorizontalComponentAlignment(Alignment.CENTER, submitFld);
Anchor forgotPasswordFld = new Anchor();
forgotPasswordFld.setText("Forgot Password?");
verticalLayout.add(forgotPasswordFld);
verticalLayout.setHorizontalComponentAlignment(Alignment.CENTER, forgotPasswordFld);
final Animator animator = Animator.create();
add(animator);
AnimatedComponent animatedLabel = animator.prepareComponent(verticalLayout);
animatedLabel.registerEntranceEffect(EntranceEffect.bounceIn);
animatedLabel.animate();
}
As you are using an entrance animation, you don’t have to call the animate() method. The animation will be done automatically after you added the component to the UI. Just register the entrance animation like this: