Skip to content

Instantly share code, notes, and snippets.

@vitalyp
Created March 14, 2015 08:50
Show Gist options
  • Save vitalyp/5f5fbeb36ff2b3c963ff to your computer and use it in GitHub Desktop.
Save vitalyp/5f5fbeb36ff2b3c963ff to your computer and use it in GitHub Desktop.
Single line Pendulum stroke algorythm
var inc = 1,
slideCount = 30,
slideIndex = 1;
// PENDULUM ANIMATION
// -------------------------------
function doPendulum() {
slideIndex += (inc *= (((slideIndex >= slideCount-1 || slideIndex <= 0 ) && -1) || 1));
}
// where:
// inc - slide index increment (-1 or 1)
// slideIndex - index of current slide, E=>[0..slideIndex)
// slideCount - index of last slide (0.png, 1.png, ..., slideCount.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment