From f26ee7950e9d41b266287e2c39b8e9e26b4d634c Mon Sep 17 00:00:00 2001 From: Typhon Date: Wed, 13 Jun 2018 09:54:57 +0200 Subject: [PATCH] RollIn & RollOut --- src/animatefx/animation/RollIn.java | 44 ++++++++++++++++++++++++++++ src/animatefx/animation/RollOut.java | 43 +++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/animatefx/animation/RollIn.java create mode 100644 src/animatefx/animation/RollOut.java diff --git a/src/animatefx/animation/RollIn.java b/src/animatefx/animation/RollIn.java new file mode 100644 index 0000000..f1ba044 --- /dev/null +++ b/src/animatefx/animation/RollIn.java @@ -0,0 +1,44 @@ +package animatefx.animation; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollIn { + + /** + * Create new RollIn + * + * @param node The node to affect + */ + public RollIn(Node node) { + RollIn(node); + } + + private void RollIn(Node node) { + + Timeline t = + new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(node.opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(node.translateXProperty(), -node.getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(node.rotateProperty(), -120, AnimateFXInterpolator.EASE) + ), + + new KeyFrame(Duration.millis(1000), + + new KeyValue(node.opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(node.translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(node.rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + ); + t.play(); + } +} + diff --git a/src/animatefx/animation/RollOut.java b/src/animatefx/animation/RollOut.java new file mode 100644 index 0000000..0036b34 --- /dev/null +++ b/src/animatefx/animation/RollOut.java @@ -0,0 +1,43 @@ +package animatefx.animation; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollOut { + + /** + * Create new RollOut + * + * @param node The node to affect + */ + public RollOut(Node node) { + RollOut(node); + } + + private void RollOut(Node node) { + + Timeline t = + new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(node.opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(node.translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(node.rotateProperty(), 0, AnimateFXInterpolator.EASE) + ), + + new KeyFrame(Duration.millis(1000), + new KeyValue(node.opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(node.translateXProperty(), node.getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(node.rotateProperty(), 120, AnimateFXInterpolator.EASE) + ) + ); + t.play(); + } +} +