mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Animator: added constructor that allows passing a runnable that is invoked at the end of the animation, which allows using lambdas in most cases
This commit is contained in:
@@ -115,26 +115,20 @@ public class FlatAnimatedLafChange
|
||||
return;
|
||||
|
||||
// create animator
|
||||
animator = new Animator( duration, new Animator.TimingTarget() {
|
||||
@Override
|
||||
public void timingEvent( float fraction ) {
|
||||
if( fraction < 0.1 || fraction > 0.9 )
|
||||
return; // ignore initial and last events
|
||||
animator = new Animator( duration, fraction -> {
|
||||
if( fraction < 0.1 || fraction > 0.9 )
|
||||
return; // ignore initial and last events
|
||||
|
||||
alpha = 1f - fraction;
|
||||
alpha = 1f - fraction;
|
||||
|
||||
// repaint snapshots
|
||||
for( Map.Entry<JLayeredPane, JComponent> e : map.entrySet() ) {
|
||||
if( e.getKey().isShowing() )
|
||||
e.getValue().repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
hideSnapshot();
|
||||
animator = null;
|
||||
// repaint snapshots
|
||||
for( Map.Entry<JLayeredPane, JComponent> e : map.entrySet() ) {
|
||||
if( e.getKey().isShowing() )
|
||||
e.getValue().repaint();
|
||||
}
|
||||
}, () -> {
|
||||
hideSnapshot();
|
||||
animator = null;
|
||||
} );
|
||||
|
||||
animator.setResolution( resolution );
|
||||
|
||||
Reference in New Issue
Block a user