I set up animation, but how to make it run only once per session. What I need to put in conditions?
Hey @Illarion ,
you could use the code-element to execute the following javascript at page load:
<script>
// Store a value in sessionStorage
sessionStorage.setItem('my_key', 'my_value');
</script>
Hi, @Tobsen
Unfortunately, it didn’t work for me. Can some plugins (like WP Rocket) be an issue?
My bad, sry. The problem was that the js-code got executed before the interaction and so the data was always set in the session-storage and the interaction-condition always false.
Try the following instead:
<script>
var counter = sessionStorage.getItem('page_loaded_counter');
if (counter === null) {
counter = 0;
} else {
counter = parseInt(counter);
}
counter++;
sessionStorage.setItem('page_loaded_counter', counter);
</script>
1 Like
It worked, thank you!
1 Like