-
Notifications
You must be signed in to change notification settings - Fork 784
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
Allow resizing from top and left edges in addition to bottom and right #145
Conversation
33d93ef
to
f012ff8
Compare
when I click on the left edge (a absolutely positioned div with class
|
on click of the ".resize-w" div: I made 100% sure that when I called |
Thanks for bringing this up. I'm working on a fix for this and some other issues. |
interact(target).resizable({ edges: { left: document.getElementById('left-resize-handle'), ... } });
@railsjedi The issue you faced should be fixed now. |
I've also allowed specific elements to be provided as the values for the resize edge properties. This might be necessary if your resize handles aren't within the element being resized (at the moment, the selector is tested only on the pointer event target). update: handle elements must be children of the target resizable unles you use |
@taye awesome, i just gave it a try with the new code on the branch and it fixed my issues. seems to be working great now, i'll keep pounding on it and let you know if i see any other issues |
@taye, I've been trying to test this branch out, for the ability to drag on the left edge, and I cannot seem to get the correct code. I cloned the repo, did a "git checkout d86ed02", which would be the change from 6 days ago "Merge branch 'master' into four-direction-resize" but I'm obviously doing something wrong. I've been using the built JS file in the root directory btw. Any help from someone who has successfully pulled (@railsjedi) and used this working branch would be much appreciated... I'm excited to get this working... |
@spxis I think |
@taye Hi, I've tried your file you linked and it worked, thanks to your work. By the way, I expected to see two-way arrow when I mouseover to the edges but I couldn't. Is it intended? or I'm wrong? |
@jjgjoojis yeah, that's wrong. I forgot about implementing cursor styling. It's good to hear that it works well aside from that. Thanks! |
@jjgjoojis Cursor styles should be working now :D |
interact(target).resizable({ edges: { left: true, right: true, top: true, bottom: true }, invert: 'reposition' || 'negate' || 'none' }); - 'none' will limit the resize rect to a minimum of 0x0 - 'negate' will alow the rect to have negative width/height - 'reposition' will keep the width/height positive by swapping the top and bottom edges and/or swapping the left and right edges
I have tried this branch and it works like a charm! I don't experience any issues so far. |
This has been merged so 4-edge resizing can be used from the master branch. I've left out snapping and restriction fixes for now. A new release should happen soon :). Thanks for all the feedback! |
May I jump on here and ask a question regarding the top and left resizing feature? I have implemented a check so resizing would not cause overlapping with other boxes of my application. However, while I can stop the resize operation, I seem not to understand how to do this properly. Which property gives me the intended new top/left positions? I tried event.rect.top, but this seems to give me the absolute (client) position which I cannot use since all other coordinates are relative to the surrounding element. So I tried to track the event.target.style.top + event.deltaRect.top, but this seems to give me wrong coordinates on every nth call. I can stop the resize properly, but the width/height will grow to make up for a move that did not occur. How can this be handled properly? |
@cubistico can you make a small demo? |
@taye Thanks for getting back. In the meantime, I have realized that I should keep track of the movement in separate variables. The problem was that I blocked movement but added the event.deltaRect properties to the actual current position, so little pointer movements made my listener think, the element would move back a little from the position where movement was stopped instead of the virtual blocked position. I hope I could make clear what I mean... |
@cubistico using the new |
@taye Thanks, I will check them out shortly! |
If resize edges are used, resize events will have
rect
anddeltaRect
properties. Inresizestart
,rect
will be identical to the rect returned byinterctable.getRect(element)
anddeltaRect
will have all-zero properties.rect
is updated on eachresizemove
and the values indeltaRect
reflect the changes.Resize handle elements must be children of the resizable element. If you need the handles to be outside the target element, then you will need to use
Interaction#start
.Resize edges are disabled by default in order to remain backwards compatible with the old resize
axis
API. The old API will be removed in future.TODO:
Sensible restriction and snapping (Resize restriction is broken #84)(Will be attempted later)Closes #37