0

So, I am developing a responsive web tool that is built around the jQuery UI's Draggable function. There is also the use of CSS's transition: scale(X, Y) in there as well.

My issue is; When I scale an object inside of a container, the object is limited in the location of where I can drag it in the container. For a physical demo of this issue, please visit this CodePen.

The code is very basic, in the fact that the only Javascript is as follows:

$(function() {

    $('.workspaceObjects').draggable({

        containment: $('#ui_workspace'),

    });

});

So, it appears to be more of a CSS issue, but it has been puzzling me for a while now, and it is something that needs to be fixed to allow further development of my web tool. What can I do to fix this issue?

2
  • any particular reason why you're scaling the element? Commented Jun 16, 2015 at 19:41
  • Basically, the container's size is increased to give it a zoom in effect. The scale of the object would increase to 1 when zooming was done, but so that the content of an object, such as text and images is displayed in a smaller scale, the element has been given the scale property. Commented Jun 16, 2015 at 19:43

1 Answer 1

1

Solved using negative margin of 20px for the draggable, and centered the transform-origin to keep it balanced.

#container_object {
    transform-origin: 50% 50%;
    margin: -20px -20px
}

See http://codepen.io/anon/pen/KpvBgJ

Sign up to request clarification or add additional context in comments.

2 Comments

I noticed that the object jumps away from the mouse. How would I prevent this?
Have a look at this, might solve your issue: stackoverflow.com/questions/13230437/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.