if (contentScrollPane.getVvalue() != contentScrollPane.getVmin()) {
// Need to scroll to the top before dropping the project widget in.
scrollToTop().setOnFinished(ev -> slideInNewProject(project));
return;
}
ProjectOverviewWidget projectWidget = buildProjectWidget(project);
// Hack: Add at the end for the size calculation, then we'll move it to the start after the next frame.
projectWidget.setVisible(false);
projectsVBox.getChildren().add(projectWidget);
// Slide in from above.
Platform.runLater(() -> {
double amount = projectWidget.getHeight();
amount += projectsVBox.getSpacing();
contentHBox.setTranslateY(-amount);
TranslateTransition transition = new TranslateTransition(Duration.millis(1500), contentHBox);
transition.setFromY(-amount);
transition.setToY(0);
transition.setInterpolator(new ElasticInterpolator(EasingMode.EASE_OUT));
transition.setDelay(Duration.millis(1000));
transition.play();
// Re-position at the start.
projectsVBox.getChildren().remove(projectWidget);
projectsVBox.getChildren().add(0, projectWidget);
projectWidget.setVisible(true);
});
}