Search code examples
jqueryjquery-uirotationjquery-ui-droppable

Update rotation draggable jQuery UI 1.8.18 to UI 1.11.4


The rotation draggable it works perfectly in version UI 1.8.18:

http://jsfiddle.net/avPf6/1/

But in version UI 1.11.4 does not work this part:

drag: function(event, ui){
    var rotateCSS = 'rotate(' + ui.position.left + 'deg)';

    $(this).parent().css({
        '-moz-transform': rotateCSS,
        '-webkit-transform': rotateCSS
    });

http://jsfiddle.net/avPf6/1/

How do I properly update this function to work in the current version of the jquery ui?

Thanks for any help


Solution

  • Probably the handle has some upgradation in 1.11.4 can check here

    You don't need handle as the element for the drag(rotate here) to occur is on the draggable element itself.

    Working solution:

    $('#handle').draggable({  
        opacity: 0.01, 
        helper: 'clone',
        drag: function(event, ui ){
            console.log(ui);
            var rotateCSS = 'rotate(' + ui.position.left + 'deg)';
    
            $(this).parent().css({
                '-moz-transform': rotateCSS,
                '-webkit-transform': rotateCSS
            });
        }
    });
    

    FIDDLE