-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimations.java
More file actions
60 lines (56 loc) · 1.94 KB
/
Animations.java
File metadata and controls
60 lines (56 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import javafx.animation.FadeTransition;
import javafx.animation.ScaleTransition;
import javafx.animation.TranslateTransition;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.util.Duration;
public class Animations {
public static void fadeIn(Node node) {
node.setOpacity(0);
FadeTransition ft = new FadeTransition(Duration.millis(320), node);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
}
public static void applyButtonHover(Button btn) {
if (btn == null) return;
final DropShadow hoverShadow = new DropShadow(10, Color.rgb(2,6,23,0.12));
btn.setOnMouseEntered(e -> {
ScaleTransition st = new ScaleTransition(Duration.millis(120), btn);
st.setToX(1.04);
st.setToY(1.04);
st.play();
btn.setEffect(hoverShadow);
});
btn.setOnMouseExited(e -> {
ScaleTransition st = new ScaleTransition(Duration.millis(120), btn);
st.setToX(1.0);
st.setToY(1.0);
st.play();
btn.setEffect(null);
});
}
public static void applyCardHover(Node n) {
if (n == null) return;
n.setOnMouseEntered(e -> {
TranslateTransition tt = new TranslateTransition(Duration.millis(140), n);
tt.setToY(-4);
tt.play();
ScaleTransition st = new ScaleTransition(Duration.millis(140), n);
st.setToX(1.02);
st.setToY(1.02);
st.play();
});
n.setOnMouseExited(e -> {
TranslateTransition tt = new TranslateTransition(Duration.millis(140), n);
tt.setToY(0);
tt.play();
ScaleTransition st = new ScaleTransition(Duration.millis(140), n);
st.setToX(1.0);
st.setToY(1.0);
st.play();
});
}
}