Skip to content

Commit

Permalink
Fixes #29
Browse files Browse the repository at this point in the history
-Hamburger now transitions when you click any of the buttons in drawer
  • Loading branch information
claude-peon committed Oct 29, 2016
1 parent 4c4d2c5 commit a890f35
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class MainController implements MainAppReceiver {
@FXML
private StackPane mainPane;

private HamburgerBackArrowBasicTransition transition;

@Override
public void setMainApp(MainFXApplication mainApp) {
this.mainApp = mainApp;
Expand All @@ -38,11 +40,15 @@ public void setMainApp(MainFXApplication mainApp) {
showMap();
}

/**
* Creates a hamburger that pulls out a drawer when clicked. It also
* transitions to an arrow when clicked and back when clicked again.
* This is used as the primary method to navigate the app.
*/
@FXML
private void initialize() {

HamburgerBackArrowBasicTransition transition = new HamburgerBackArrowBasicTransition(hamburger);
transition.setRate(-1);
transitionHelper();
hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED,(e)-> {
transition.setRate(transition.getRate() * -1);
transition.play();
Expand All @@ -60,12 +66,14 @@ private void initialize() {
}

/**
* Expands/retracts the drawer when user presses the hamburger.
* A private helper method to allow constant use of the hamburger
* transition across multiple methods in the class without having
* to create new instance of the HamburgerBackArrowBasicTransition
*/
@FXML
private void handleHamburgerPressed(ActionEvent event) {


private void transitionHelper() {
transition = new
HamburgerBackArrowBasicTransition(hamburger);
transition.setRate(-1);
}

/**
Expand All @@ -90,6 +98,8 @@ private void handleEditProfile(ActionEvent event) {
* Slides the drawer shut.
*/
public void closeDrawer() {
transition.setRate(-1);
transition.play();
drawer.close();
}

Expand Down

0 comments on commit a890f35

Please sign in to comment.