Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back-button-click animation #14

Open
jonhue opened this issue Jul 7, 2018 · 4 comments
Open

Back-button-click animation #14

jonhue opened this issue Jul 7, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@jonhue
Copy link
Owner

jonhue commented Jul 7, 2018

Similar to inline animations. Specify a specific animation for when a user clicks on the back button.

@jonhue jonhue added the enhancement New feature or request label Jul 7, 2018
@jonhue jonhue self-assigned this Jul 7, 2018
@jonhue jonhue removed their assignment Sep 4, 2018
@snellingio
Copy link

I'd love to see this feature. Any thoughts on how this could be done?

@snellingio
Copy link

A little hacky

let goingBack = false;

document.addEventListener('turbolinks:load', function (event) {
    if (goingBack) {
        window.TurbolinksAnimate.init({animation: 'fadeOutRight'});
        goingBack = false;
    } else {
        window.TurbolinksAnimate.init({animation: 'fadeIn'});
    }
});

window.onpopstate = function () {
    goingBack = true;
};

Popstate fires before the load event.

@jonhue
Copy link
Owner Author

jonhue commented Feb 7, 2019

@snellingio your take on this looks good, but we have to think about an interface (maybe similar to inline animations) that allows you to specify the desired back-animation in HTML or JS.

@snellingio
Copy link

Well, actually after playing with it more, onpopstate triggers on both backwards and forwards interactions.

Will investigate how to determine backwards / forwards either later tonight or this weekend. On quick review, it might be slightly tricky as turbolinks is overwriting the history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants