camelmasa / animate-rails

animate.css for rails.
MIT License
99 stars 11 forks source link

How to deal with Turbolinks 5? #42

Open mrkongo opened 8 years ago

mrkongo commented 8 years ago

How to deal with Turbolinks 5?

Every time I click on a link the animation run two times!

<h1 class="animated infinite bounce">Example</h1>

Why?

nqngo commented 8 years ago

This is due to caching feature in Turbolinks 5. See this section of the README:

Otherwise, during standard navigation (via Application Visits), Turbolinks will immediately restore the page from cache and display it as a preview while simultaneously loading a fresh copy from the network. This gives the illusion of instantaneous page loads for frequently accessed locations.

To prevent the animation display twice, a quick hack is to disable the preview cache. Read Opting out of caching and add this to your <head>

<meta name="turbolinks-cache-control" content="no-preview">