Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize example #36

Closed
dhqvinh opened this issue Jun 25, 2014 · 1 comment
Closed

Resize example #36

dhqvinh opened this issue Jun 25, 2014 · 1 comment

Comments

@dhqvinh
Copy link

dhqvinh commented Jun 25, 2014

I'm working a dashboard that needs drag & drop widgets, resizeable. Interact.js seems to be good to our need, but I cannot find an example of how to implement resizable, can you help?

Thanks.

@taye
Copy link
Owner

taye commented Jun 25, 2014

Here's a quick example: http://codepen.io/taye/pen/xIkdz. I'll also put one on interactjs.io soon.

interact('.resize')
  .resizeable(true)
  .on('resizemove', function (event) {
    var target = event.target;

    // add the change in coords to the previous width of the target element
    var
      newWidth  = parseFloat(target.style.width ) + event.dx,
      newHeight = parseFloat(target.style.height) + event.dy;

    // update the element's style
    target.style.width  = newWidth + 'px';
    target.style.height = newHeight + 'px';

    target.textContent = newWidth + '×' + newHeight;
  });

@taye taye closed this as completed Jul 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants