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

Resizable handle outside the target element #188

Closed
vlatkoodrljin opened this issue May 12, 2015 · 7 comments
Closed

Resizable handle outside the target element #188

vlatkoodrljin opened this issue May 12, 2015 · 7 comments

Comments

@vlatkoodrljin
Copy link

How i can place resizable handle outside the target element regarding draggable example below? I can't find any working example, help please.

interact(target)
  .draggable({
        manualStart: true
    })
   .on('hold', function (event) {
        var interaction = event.interaction;

      if (!interaction.interacting()) {
  interaction.start({ name: 'drag' },
                    event.interactable,
                    event.currentTarget);
}
});
@taye
Copy link
Owner

taye commented May 13, 2015

I can't make a full demo now. The general idea is to listen for down (or move) events on the handles and then manually start a resize action on the element that the handle is for.

<!-- Resize handle.
     the data-[edge] attributes hold the edges that the handle can resize --> 
<div class="resize-handle" data-right="true" data-bottom="true"></div>

<!-- The element that the handle resizes --> 
<div id="resizable-element"></div>
interact('#resize-element').resizable(...);

interact('.resize-handle').on('down', function (event) {
  var interaction = event.interaction,
      handle = event.currentTarget;

  interaction.start({
      name: 'resize',
      edges: {
        top   : handle.dataset.top,
        left  : handle.dataset.left,
        bottom: handle.dataset.bottom,
        right : handle.dataset.right,
      }   
    },  
    interact('#resizable-element'),               // target Interactable
    document.getElementByID('resize-element'));   // target Element
});

I didn't test the code above by the way.

@taye
Copy link
Owner

taye commented Jun 21, 2015

Here is a working demo http://codepen.io/taye/pen/pJWQRx.

@alexiskattan
Copy link

Could something like this be added to the library? Making it clear that an object is resizable would help with discoverability. Maybe an option of add handles in resizable...

@taye
Copy link
Owner

taye commented Jun 22, 2015

I feel that that's something that should be implemented in a separate library on top of interact.js so I'm against adding it directly. I might change my mind in the future but I don't think that it's likely.

And by the way, I've improved that demo a little.

@taye taye closed this as completed Jun 22, 2015
@ydatech
Copy link

ydatech commented Oct 27, 2016

@taye the demo ([http://codepen.io/taye/pen/pJWQRx]) doesn't work. why?

@zorentsl
Copy link

I was able to get the codepen to work by editing the interact library.
On line 1752 of interact.js in the start function, I changed
this.setEventXY(this.startCoords);
to
this.setEventXY(this.startCoords, this.pointers);

I might make a PR for this change. It looks like pointers is a required parameter for setEventXY.

@zorentsl
Copy link

Once I've started down this road....
A possible change to the demo:
interaction.start({
name: 'resize',
edges: {
top : handle.dataset.top,
left : handle.dataset.left,
bottom: handle.dataset.bottom,
right : handle.dataset.right,
}
},
should be
interaction.start({
name: 'resize',
edges: {
top : (handle.dataset.top == "true"),
left : (handle.dataset.left == "true"),
bottom: (handle.dataset.bottom == "true"),
right : (handle.dataset.right == "true"),
}
},

zorentsl added a commit to zorentsl/interact.js that referenced this issue Dec 19, 2016
taye pushed a commit that referenced this issue Dec 19, 2016
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

5 participants