public DrawerLayout() { AnchorPane.setTopAnchor(toggleLayer, 0d); AnchorPane.setRightAnchor(toggleLayer, 0d); AnchorPane.setBottomAnchor(toggleLayer, 0d); AnchorPane.setLeftAnchor(toggleLayer, 0d); toggleLayer.setBackground( new Background(new BackgroundFill(Color.BLACK, new CornerRadii(0d), new Insets(0)))); toggleLayer.setOpacity(0); toggleLayer.setVisible(false); toggleLayer.setOnMouseClicked( evt -> { if (evt.getButton().equals(MouseButton.PRIMARY)) { if (drawerOpened) { closeDrawer(); } } }); tableScreen.bind(widthProperty().lessThan(responsiveWidth).or(responsiveWidth.isEqualTo(0))); tableScreen.addListener( (observable, oldValue, newValue) -> { responsiveBehavior(newValue); }); }
private void drawerAnimation() { Timeline animation; if (drawerOpened) { toggleLayer.setVisible(true); animation = new Timeline( new KeyFrame( DEFAULT_TIME_ANIM, new KeyValue(nav.translateXProperty(), 0, Interpolator.EASE_OUT), new KeyValue(toggleLayer.opacityProperty(), 0.3))); } else { animation = new Timeline( new KeyFrame( DEFAULT_TIME_ANIM, new KeyValue(nav.translateXProperty(), -DEFAULT_WIDTH_NAV, Interpolator.EASE_IN), new KeyValue(toggleLayer.opacityProperty(), 0))); animation.setOnFinished( evt -> { toggleLayer.setOpacity(0); toggleLayer.setVisible(false); }); } animation.play(); }