Skip to content

Instantly share code, notes, and snippets.

@daithiocrualaoich
Created December 12, 2012 16:20
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 daithiocrualaoich/4269195 to your computer and use it in GitHub Desktop.
Save daithiocrualaoich/4269195 to your computer and use it in GitHub Desktop.
Circular impress.js slide layout in Javascript
var steps = document.getElementsByClassName("step");
var r = 2000;
for (var i = 0; i < steps.length; i++) {
var theta = -i/(steps.length-1) * 2 * Math.PI;
var x = r * Math.cos(theta);
var y = r * Math.sin(theta);
var rotation = theta/(2*Math.PI) * 360 - 90;
steps[i].setAttribute("data-x", Math.round(x).toString());
steps[i].setAttribute("data-y", Math.round(y).toString());
steps[i].setAttribute("data-rotate-z", Math.round(rotation).toString());
}
var overview = document.getElementById("overview");
overview.setAttribute("data-x", "0");
overview.setAttribute("data-y", "0");
overview.setAttribute("data-scale", "5");
// Disable click to move to step.
document.addEventListener("click", function() { event.cancelBubble = true; }, true);
impress().init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment