Java源码示例:gwt.material.design.client.ui.animate.MaterialAnimation
示例1
public void testAnimation() {
MaterialPanel panel = new MaterialPanel();
RootPanel.get().add(panel);
MaterialAnimation animation = new MaterialAnimation();
animation.delay(0);
assertEquals(animation.getDelay(), 0);
animation.infinite(true);
assertTrue(animation.isInfinite());
animation.infinite(false);
assertFalse(animation.isInfinite());
animation.duration(20);
assertEquals(animation.getDuration(), 20);
animation.transition(Transition.FADEIN);
assertEquals(animation.getTransition(), Transition.FADEIN);
animation.animate(panel);
assertEquals(animation.getWidget(), panel);
// Check Advance Logic
String WEBKIT_ANIMATION_DURATION = panel.getElement().getStyle().getProperty("WebkitAnimationDuration");
assertEquals(WEBKIT_ANIMATION_DURATION, animation.getDuration() + "ms");
}
示例2
@Override
public void setPageTitle(String title, String description, String link, String specification) {
this.title.setText(title);
this.description.setText(description);
this.link = link;
this.specification = specification;
if (link.isEmpty()) {
chipJava.setVisible(false);
chipXml.setVisible(false);
} else {
chipJava.setVisible(true);
chipXml.setVisible(true);
}
if (specification.isEmpty()) {
chipSpecification.setVisible(false);
} else {
chipSpecification.setVisible(true);
}
new MaterialAnimation().transition(Transition.BOUNCEINLEFT).animate(this.title);
new MaterialAnimation().transition(Transition.BOUNCEINLEFT).animate(this.description);
}
示例3
@UiHandler("btnFAB")
void onFAB(ClickEvent e){
// Execute the opening callback once the fab is clicked
MaterialPathAnimator.animate(btnFAB.getElement(), musicPanel.getElement(), () -> {
// Hide the fab with zoom out animation
new MaterialAnimation().transition(Transition.ZOOMOUT).animate(btnFAB);
btnFAB.setVisibility(Style.Visibility.HIDDEN);
btnFAB.setOpacity(0);
// Setting the visibility of the music panel
musicPanel.setVisibility(Style.Visibility.VISIBLE);
musicPanel.setOpacity(1);
// Setting the music label with Bounce up animation
lblMusic.setText("Pharell Williams / Love Yourself to Dance");
new MaterialAnimation().transition(Transition.BOUNCEINUP).animate(lblMusic);
// Setting the image of the artist
imgMusic.setUrl("http://thatgrapejuice.net/wp-content/uploads/2013/08/pharrell-williams-that-grape-juice.png");
});
}
示例4
@UiHandler("btnPause")
void onPause(ClickEvent e){
// Execute the close callback animation
MaterialPathAnimator.reverseAnimate(btnFAB.getElement(), musicPanel.getElement(), () -> {
// Setting the visibility of the FAB for reverse animation
new MaterialAnimation().transition(Transition.ZOOMIN).animate(btnFAB);
btnFAB.setVisibility(Style.Visibility.VISIBLE);
btnFAB.setOpacity(1);
// Hide the music panel once the pause button is clicked
musicPanel.setVisibility(Style.Visibility.HIDDEN);
musicPanel.setOpacity(0);
// Setting the previous music label with Bounce down animation
lblMusic.setText("Lady Gaga / Telephone");
new MaterialAnimation().transition(Transition.BOUNCEINDOWN).animate(lblMusic);
// Setting the image of the artist
imgMusic.setUrl("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRi9lfCkLutb7ugJlIjn84qWNoiICopC-Vyx7QQJRHF5E7GlqFG");
});
}
示例5
@Override
public void animateNext() {
MaterialStep currentStep = stepper.getCurrentStep();
MaterialStep nextStep = stepper.getStep(currentStep.getStep() + 1);
if (currentStep != null && nextStep != null) {
if (enableTransition && stepper.getAxis() == Axis.HORIZONTAL) {
currentStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
new MaterialAnimation().transition(nextOutTransition).animate(currentStep.getConBody(), () -> {
currentStep.setActive(false);
currentStep.getDivBody().setOverflow(Style.Overflow.AUTO);
});
nextStep.setActive(true);
new MaterialAnimation().transition(nextInTransition).animate(nextStep.getConBody());
} else {
currentStep.setActive(false);
nextStep.setActive(true);
}
}
}
示例6
@Override
public void animatePrevious() {
MaterialStep currentStep = stepper.getCurrentStep();
MaterialStep previousStep = stepper.getStep(currentStep.getStep() - 1);
if (currentStep != null && previousStep != null) {
if (enableTransition && stepper.getAxis() == Axis.HORIZONTAL) {
currentStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
new MaterialAnimation().transition(previousOutTransition).animate(currentStep.getConBody(), () -> {
currentStep.setActive(false);
currentStep.getDivBody().setOverflow(Style.Overflow.AUTO);
});
previousStep.setActive(true);
previousStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
new MaterialAnimation().transition(previousInTransition).animate(previousStep.getConBody(), () -> {
previousStep.getDivBody().setOverflow(Style.Overflow.AUTO);
});
} else {
currentStep.setActive(false);
previousStep.setActive(true);
}
}
}
示例7
private void animate() {
String value = lstAnimations.getSelectedValue();
Transition transition = Transition.fromStyleName(value);
MaterialAnimation animation = new MaterialAnimation();
animation.setTransition(transition);
animation.setDelay(0);
animation.setDuration(1000);
animation.setInfinite(false);
animation.animate(card);
}
示例8
@UiHandler("btnAnimateInfinite")
void onAnimateInfinite(ClickEvent e) {
infiniteAnimation = new MaterialAnimation();
infiniteAnimation.setDelay(0);
infiniteAnimation.setTransition(Transition.PULSE);
infiniteAnimation.setDuration(1000);
infiniteAnimation.setInfinite(true);
infiniteAnimation.animate(iconHeart);
}
示例9
@UiHandler("btnAnimateCallback")
void onCallback(ClickEvent e) {
MaterialAnimation animation = new MaterialAnimation();
animation.setDelay(0);
animation.setDuration(1000);
animation.transition(Transition.FLIPINX);
animation.animate(iconCallback, () -> {
MaterialToast.fireToast("Animation is finished");
});
}
示例10
@Inject
ScrollFireView(Binder uiBinder) {
initWidget(uiBinder.createAndBindUi(this));
MaterialScrollfire.apply(panel.getElement(), () -> {
MaterialToast.fireToast("Toasted");
});
MaterialScrollfire.apply(listContainer.getElement(), () -> new MaterialAnimation().transition(Transition.SHOW_STAGGERED_LIST).animate(listContainer));
MaterialScrollfire.apply(image.getElement(), () -> new MaterialAnimation().transition(Transition.FADE_IN_IMAGE).animate(image));
}
示例11
public void animate() {
if (!animated) {
new MaterialAnimation().transition(Transition.FADEIN).delay(0).duration(600).animate(image, () -> {
image.setOpacity(1);
titleLabel.setOpacity(1);
descriptionLabel.setOpacity(1);
new MaterialAnimation().transition(Transition.SLIDEINRIGHT).animate(titleLabel);
new MaterialAnimation().transition(Transition.SLIDEINRIGHT).animate(descriptionLabel);
});
animated = true;
}
}
示例12
public void reset(Widget target, int delay) {
new MaterialAnimation().transition(Transition.BOUNCEOUTDOWN).delay(delay).animate(this, () -> {
target.setVisible(true);
new MaterialAnimation().transition(Transition.BOUNCEINUP).animate(target, () -> {
RootPanel.get().getElement().getStyle().clearOverflow();
target.setVisible(true);
});
setVisible(false);
});
}
示例13
public void setState(State state, String title, String description) {
this.state = state;
setTitle(title);
setDescription(description);
setVisible(true);
if (isAnimation()) {
new MaterialAnimation().transition(Transition.BOUNCEIN).animate(icon);
new MaterialAnimation().transition(Transition.BOUNCEINUP).animate(lblTitle);
new MaterialAnimation().transition(Transition.BOUNCEINUP).animate(lblDescription);
}
if (state == State.LOADING) {
icon.setIconType(IconType.LOOP);
icon.setBackgroundColor(Color.WHITE);
icon.setIconColor(Color.BLACK);
LoadingEvent.fire(this);
loader.show();
} else if (state == State.SUCCESS) {
loader.hide();
icon.setIconType(IconType.CHECK);
icon.setBackgroundColor(Color.BLUE);
icon.setIconColor(Color.WHITE);
SuccessEvent.fire(this);
} else if (state == State.ERROR) {
loader.hide();
icon.setIconType(IconType.ERROR);
icon.setBackgroundColor(Color.RED);
icon.setIconColor(Color.WHITE);
ErrorEvent.fire(this);
}
}
示例14
public PathAnimatorShowcase() {
initWidget(uiBinder.createAndBindUi(this));
new MaterialAnimation().transition(Transition.BOUNCEINDOWN).animate(btnFAB);
}
示例15
@UiHandler("btnCloseGrid")
void onCloseGrid(ClickEvent e) {
MaterialAnimation gridAnimation = new MaterialAnimation();
gridAnimation.setTransition(Transition.CLOSE_GRID);
gridAnimation.animate(gridPanel);
}
示例16
@UiHandler("btnShowGrid")
void onShowGrid(ClickEvent e) {
MaterialAnimation gridAnimation = new MaterialAnimation();
gridAnimation.setTransition(Transition.SHOW_GRID);
gridAnimation.animate(gridPanel);
}
示例17
@UiHandler("btnStaggered")
void onStaggered(ClickEvent e) {
MaterialAnimation gridAnimation = new MaterialAnimation();
gridAnimation.setTransition(Transition.SHOW_STAGGERED_LIST);
gridAnimation.animate(listContainer);
}
示例18
@UiHandler("btnFade")
void onFade(ClickEvent e) {
MaterialAnimation gridAnimation = new MaterialAnimation();
gridAnimation.setTransition(Transition.FADE_IN_IMAGE);
gridAnimation.animate(image);
}
示例19
@UiHandler("btnShow")
void onShow(ClickEvent e) {
new MaterialAnimation().transition(Transition.SHOW_GRID).animate(rowCards);
}
示例20
public void setOpenAnimation(final MaterialAnimation openAnimation) {
this.openAnimation = openAnimation;
}
示例21
public void setCloseAnimation(final MaterialAnimation closeAnimation) {
this.closeAnimation = closeAnimation;
}