Skip to content

Instantly share code, notes, and snippets.

@seliopou
Created November 20, 2012 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seliopou/4120660 to your computer and use it in GitHub Desktop.
Save seliopou/4120660 to your computer and use it in GitHub Desktop.
A Conditional Animation Pattern for d3 - script tag
<form>
<input id="back_detect" type="hidden" name="back_detect" value="" />
</form>
<script type="text/javascript">
/* Render vis, animating only if value is set to "" */
vis("#canvas", $("#back_detect").val() == "");
/*
* Set the value of the form field to "visited". Most browsers will
* preserve this when the user navigates with the back button.
*/
$("#back_detect").val("visited");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment