Created
October 17, 2012 22:26
-
-
Save eliasgs/3908732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id=wrapper> | |
<div class=seat></div> | |
<div class=seat></div> | |
<div class=seat></div> | |
<div class=seat></div> | |
<div class=seat></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function ($){ | |
var radius = 250; | |
var center = { left: 250, bottom: 500 }; | |
var pi = Math.PI; | |
var distribute = { from: 5*pi/4, to: 7*pi/4 }; | |
var curve = function (angle){ | |
return { | |
left: radius*Math.cos(angle)+center.left, | |
bottom: radius*Math.sin(angle)+center.bottom | |
}; | |
}; | |
var n = $('.seat').length-1; | |
var delta = Math.abs(distribute.from-distribute.to)/n; | |
$('.seat').css('position', 'absolute'); | |
$('.seat').css('margin', 0); | |
$('.seat').each(function (i,e){ | |
var angle = i*delta+distribute.from; | |
var pos = curve(angle); | |
$(e).css({ | |
left: pos.left, | |
bottom: pos.bottom, | |
'-webkit-transform': 'rotate(-'+angle+'rad)' | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { background: silver; } | |
#wrapper{ | |
position: relative; | |
margin: 10px; | |
width: 500px; | |
height: 500px; | |
border: 1px dashed grey; | |
} | |
.seat{ | |
float: left; | |
margin: 10px; | |
width: 50px; | |
height: 50px; | |
background: brown; | |
-webkit-transform-origin: center center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment