Skip to content

Instantly share code, notes, and snippets.

@bdotdub
Created December 10, 2009 20:03
Show Gist options
  • Save bdotdub/253619 to your computer and use it in GitHub Desktop.
Save bdotdub/253619 to your computer and use it in GitHub Desktop.
function rotatePages() {
if (navigator.appVersion.indexOf('iPhone OS ') < 0) { // Don't rotate on iPhone.
posts = document.getElementsByClassName('postRotationContainer');
for (i = 0; i < posts.length; i++) {
// console.log("Post "+i+": Height: "+posts[i].clientHeight+" Current:"+posts[i].style.webkitTransform);
if (typeof posts[i].parentNode.className == 'string' // we can read the parent's classname
&& posts[i].parentNode.className.indexOf('noRotation') < 1 // - and it's not set to noRotation
&& ! posts[i].style.webkitTransform) // - and not already rotated
{
posts[i].style.webkitTransform = 'rotate(' + ((Math.random() * maxRotationAngle * 2) - maxRotationAngle) + 'deg)';
posts[i].style.MozTransform = 'rotate(' + ((Math.random() * maxRotationAngle * 2) - maxRotationAngle) + 'deg)';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment