:ocean: Modern animation library for JavaFX.
AnimatedSlider
, a Slider
implementation that dynamically animates its value.Animation callbacks were added to:
AnimationProperty
AnimatedValue
, including AnimatedValueLabel
Animation
transition
The callback for Animation
(used for AnimateFX-based features, such as switchers and animated containers) is extremely simple:
Animation animation = new Animation(new FadeIn());
animation.setOnFinished(e -> ...);
For the sake of usability, a fluent setter was also added:
Animation animation = new Animation(new FadeIn()).onFinished(e -> ...);
binding
The implementation for the binding
package is slightly different: the classes listed previously now feature setOnAnimationStarted
and setOnAnimationEnded
.
AnimationProperty<Double> property = AnimationProperty.of(someProperty());
property.setOnAnimationStarted(e -> ...);
property.setOnAnimationEnded(e -> ...);
They handle AnimationEvent
s that can be affected by interruptions.
From the AnimationEvent#isInterrupted()
documentation:
property.setOnAnimationEnded(e -> {
if (e.isInterrupted()) {
System.out.println("The animation was interrupted, a new one will play now");
}
})
A fluent setter is available here too:
Animated animated = new Animated(node,
new AnimatedOpacity()
.onAnimationEnded(e -> ...)
)
AnimationProperty.of(someProperty()).onAnimationStarted(e -> ...).register();
AnimatedValueLabel<Double> label = new AnimatedValueLabel<>(0.0)
.onAnimationStarted(e -> ...)
.onAnimationEnded(e -> ...);
CircleClipIn
, CircleClipOut
, RectangleClipIn
, RectangleClipOut
. They can be used the same way other AnimateFX animations are used;AnimatedThemeSwitcher
on high-DPI screens;Animation
can no longer wrap null animations. Animation.none()
now returns an instance of None
;Animation
's delay
property can now be set via FXML;AnimatedSwitcher#of
now throws an IllegalStateException
instead of IllegalAccessError
if a child is already set;Curve
was moved to the common
package.
CircleClipOut
used with anAnimatedThemeSwitcher
AnimatedValueLabel
to display some content which is implicitly animated every time its value changes: see the README for further information (example code);AnimationProperty#addBinding
to bind a property to an animated one;IntegerPropertyWrapper
to allow animated bindings for int
values;EASE_IN_ELASTIC
, EASE_OUT_ELASTIC
, EASE_IN_OUT_ELASTIC
;AnimatedThemeSwitcher#init
now throws an IllegalStateException
if it had already been initialized (related to #4);CustomizableAnimation#custom
method signature;Pausable
interface to the new common
package.It is now possible to register on-demand properties, without an Animated
node, as long as a target node is set:
new AnimatedPrefSize(node).register();
animated is getting a new major release!
binding
(implicit animations that react to changes), and transition
(features that rely on AnimateFX animations).binding
changelogThe implicit binding API has been redesigned to provide a more concise way to create implicit animations:
Animated
now accepts multiple properties at once that can also be edited later via getTargetProperties()
. AnimatedMulti
was removed.
Animated
is no longer generic.
Pre-made animated nodes (such as AnimatedOpacity
) are now properties called presets.
This lets you mix standard properties and presets within the same Animated
node with ease.
Presets also have a new zero-arguments constructor that lets the property inherit the target node from its Animated
parent.
Animated animated = new Animated(child, new AnimatedOpacity());
Animated
now requires animation properties instead of property wrappers.
You can use AnimationProperty.of
to wrap a JavaFX property instead of PropertyWrapper.of
.
Animated animated = new Animated(child, AnimationProperty.of(child.opacityProperty()));
AnimatedSize
was renamed to AnimatedPrefSize
.
AnimatedPosition
was renamed to AnimatedTranslatePosition
.
AnimatedDropShadow
was split into two different properties: AnimatedDropShadow.Color
and AnimatedDropShadow.Radius
.
Removed isActive()
and setActive(active)
from Animated
and AnimationProperty
. They now implement the Pausable
interface, with isPaused()
, pause()
, resume()
.
Removed the deprecated PropertyWrapper#createParallelProperty
method.
transition
changelogAnimateFX-based features now have empty constructors that use FadeIn
and FadeOut
as default entrance and exit animations, which can now be updated after instantiation via setIn
and setOut
. animationInProperty()
and animationOutProperty()
were also added. These classes include:
AnimatedContainer
subclasses: AnimatedHBox
and AnimatedVBox
;AnimatedSwitcher
;AnimatedLabel
.AnimatedThemeSwitcher
is now instantiated via a constructor, and the static init
method was removed.
A non-static init()
method must be called after instantiation in order to register the hook.
AnimatedThemeSwitcher themeSwitcher = new AnimatedThemeSwitcher(scene, new FadeOut());
themeSwitcher.init();
AnimatedThemeSwitcher
's previous getAnimation
was replaced with getOut
. setOut
is also available.
Fixed AnimatedLabel
not pausing correctly.
Added AnimatedSwitcher#childProperty
.
Added AnimatedLabel#currentLabelProperty
and AnimatedLabel#labelFactoryProperty
.
If you are upgrading the library from a 0.x.x version, you will most likely have a bunch of errors to fix before having a successful compilation. Here are some useful fixes:
The package layout has been changed: let your IDE find out the new location of the imported classes.
Use AnimationProperty.of
instead of PropertyWrapper.of
. Also, Animated
is no longer generic, so you can remove the diamonds.
Use AnimationProperty#register
instead of PropertyWrapper#registerAnimation
for independent animations.
Use presets instead of pre-made animated nodes:
// Before
AnimatedOpacity animated = new AnimatedOpacity(node);
// After
Animated animated = new Animated(node, new AnimatedOpacity());
Use Animated
instead of AnimatedMulti
:
// Before
AnimatedMulti animated = new AnimatedMulti(node,
PropertyWrapper.of(node.prefWidthProperty()),
PropertyWrapper.of(node.prefHeightProperty()
);
// After
Animated animated = new Animated(node,
AnimationProperty.of(node.prefWidthProperty()),
AnimationProperty.of(node.prefHeightProperty())
);
// Or even better
Animated animated = new Animated(node, new AnimatedPrefSize());
Instantiate AnimatedThemeSwitcher
via constructor instead of the static init
method:
// Before
AnimatedThemeSwitcher themeSwitcher = AnimatedThemeSwitcher.init(scene);
// After
AnimatedThemeSwitcher themeSwitcher = new AnimatedThemeSwitcher(scene, new FadeOut());
themeSwitcher.init();
Use AnimatedThemeSwitcher#get/setOut
instead of get/setAnimation
.
AnimatedSwitcher
, AnimatedContainer
, AnimatedThemeSwitcher
, ...) regarding null
animations, that aren't accepted now;Animation.none()
method (equivalent to new Animation(null)
to represent a non-animation;PropertyWrapper#registerAnimation
as a preferred alternative to new AnimationProperty(propertyWrapper).register()
.AnimationProperty
was moved out of the internal
package as a valid, flexible alternative to Animated
;PropertyWrapper.of
and the Kotlin extension function Property#animated
now feature different overloads for each supported wrapper type in order to minimize ambiguity;Automatic-Module-Name
(#2);AnimatedThemeSwitcher
is now completely implicit: it now directly affects the scene's stylesheets and does not need to be carried around;AnimatedLabel
to animate text changes;AnimatedHBox
;Curve#getCurveFunction
;internal
sub-package.AnimatedLayout
for animated repositioning when resizing a root node (example);isActive
and setActive
for Animated
and AnimatedMulti
.Fixed animations getting stuck if a bound property was updated by the user while an animation was playing.
PropertyWrapper#createParallelProperty
is now deprecated.