I've been searching long time, but can't find a better way solve my problem,
make div draggable, rotate and resize by each handle like these 2 example 1 2,, now it can be draggable, but rotate..
Regarding Prasanth K C, Chango, Yi Jiang ..'s answer, these code maybe not correct,
1. it should have a rotate point around the origin.
2. need to consider radius.
But I don't know how to use sin or cos here to make rotate consider radius?
Any suggestion will be be appreciated. http://jsfiddle.net/tBgLh/8/
var dragging = false, target_wp; $('.handle').mousedown(function(e) { var o_x = e.pageX, o_y = e.pageY; // origin point e.preventDefault(); e.stopPropagation(); dragging = true; target_wp=$(e.target).closest('.draggable_wp'); $(document).mousemove(function(e) { if (dragging) { var s_x = e.pageX, s_y = e.pageY; // start rotate point if(s_x !== o_x && s_y !== o_y){ //start rotate var s_rad = Math.atan2(s_y, s_x); var degree = (s_rad * (360 / (2 * Math.PI))); target_wp.css('-moz-transform', 'rotate(' + degree + 'deg)'); target_wp.css('-moz-transform-origin', '50% 50%'); target_wp.css('-webkit-transform', 'rotate(' + degree + 'deg)'); target_wp.css('-webkit-transform-origin', '50% 50%'); target_wp.css('-o-transform', 'rotate(' + degree + 'deg)'); target_wp.css('-o-transform-origin', '50% 50%'); target_wp.css('-ms-transform', 'rotate(' + degree + 'deg)'); target_wp.css('-ms-transform-origin', '50% 50%'); } } }) $(document).mouseup(function() { dragging = false }) })// end mousemove html
<div class="draggable_wp"> <div class="el"></div> <div class="handle"></div> </div>