Package at.bestsolution.animationutils.pagetransition.animation

Source Code of at.bestsolution.animationutils.pagetransition.animation.SlideAnimation

package at.bestsolution.animationutils.pagetransition.animation;

import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.ParallelTransitionBuilder;
import javafx.animation.TranslateTransitionBuilder;
import javafx.scene.Node;
import javafx.util.Duration;
import at.bestsolution.animationutils.pagetransition.ACenterSwitchAnimation;

public class SlideAnimation extends ACenterSwitchAnimation {

  @Override
  protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
    newNode.setOpacity(1);
   
    double deltaX = -curNode.getBoundsInLocal().getWidth();
    newNode.setTranslateX(-deltaX);
   
   
    TranslateTransitionBuilder builder = TranslateTransitionBuilder.create()
      .interpolator(Interpolator.EASE_BOTH)
      .byX(deltaX)
      .duration(new Duration(1000));
     
    return ParallelTransitionBuilder.create().children(builder.node(curNode).build(), builder.node(newNode).build()).build();
  }

  @Override
  protected void resetProperties(Node curNode, Node newNode) {
    newNode.setTranslateX(0);
    curNode.setTranslateX(0);
  }

}
TOP

Related Classes of at.bestsolution.animationutils.pagetransition.animation.SlideAnimation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.