use of com.ait.lienzo.client.core.animation.AnimationCallback in project kie-wb-common by kiegroup.
the class ShapeStateAttributeAnimationHandler method animate.
private IAnimationHandle animate(final com.ait.lienzo.client.core.shape.Shape<?> shape, final ShapeStateAttributes attributes, final long duration) {
final AnimationProperties properties = new AnimationProperties();
attributes.consume((attr, value) -> {
switch(attr) {
case FILL_COLOR:
properties.push(FILL_COLOR((String) value));
break;
case FILL_ALPHA:
properties.push(FILL_ALPHA((double) value));
break;
case STROKE_COLOR:
properties.push(STROKE_COLOR((String) value));
break;
case STROKE_ALPHA:
properties.push(STROKE_ALPHA((double) value));
break;
case STROKE_WIDTH:
properties.push(STROKE_WIDTH((double) value));
break;
}
});
return shape.animate(AnimationTweener.LINEAR, properties, duration, new AnimationCallback() {
@Override
public void onClose(final IAnimation animation, final IAnimationHandle handle) {
super.onClose(animation, handle);
if (null != animationHandle && !animationHandle.isRunning()) {
setAnimationHandle(null);
completeCallback.execute();
}
}
});
}
use of com.ait.lienzo.client.core.animation.AnimationCallback in project kie-wb-common by kiegroup.
the class ShapeStateAttributeAnimationHandlerTest method testApplyStateAnimationWithResetBeforeAnimationCompletes.
@Test
public void testApplyStateAnimationWithResetBeforeAnimationCompletes() {
final ArgumentCaptor<AnimationCallback> animationCallbackCaptor = ArgumentCaptor.forClass(AnimationCallback.class);
tested.applyState(ShapeState.SELECTED);
verify(shape, times(1)).animate(any(AnimationTweener.class), any(AnimationProperties.class), anyDouble(), animationCallbackCaptor.capture());
tested.reset();
final AnimationCallback animationCallback = animationCallbackCaptor.getValue();
animationCallback.onClose(mock(IAnimation.class), mock(IAnimationHandle.class));
}
Aggregations