Skip to content

Commit

Permalink
RollIn & RollOut
Browse files Browse the repository at this point in the history
  • Loading branch information
Typhon0 committed Jun 13, 2018
1 parent 6c65949 commit f26ee79
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/animatefx/animation/RollIn.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

43 changes: 43 additions & 0 deletions src/animatefx/animation/RollOut.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit f26ee79

Please sign in to comment.