components icon indicating copy to clipboard operation
components copied to clipboard

[Feature Request] CDK Resizable

Open cole21771 opened this issue 6 years ago • 25 comments

Please describe the feature you would like to request.

Add cdkResize (along with cdkResizeHandle) to the CDK to allow resizing of elements such as divs or any other element.

What is the use-case or motivation for this proposal?

I believe that it would complement the new drag and drop functionality very well and would be especially useful to those making dashboard like applications, such as myself..

Is there anything else we should know?

Should also probably have the similar events to the cdkDrag ones (startResizing, stopResizing, etc).

cole21771 avatar Jan 20 '19 21:01 cole21771

~~Hi @cole21771 can you point out the locations in source code where cdkResize is used in CDK?~~

sahilbabbar avatar Jan 22 '19 06:01 sahilbabbar

@sahilbabbar This is a feature request.... the point is that it is NOT in the CDK, but I would like it to be ADDED to the CDK....

Edit: So just to be clear, there are no locations in code where cdkResize is used since it doesn't exist.

cole21771 avatar Jan 22 '19 20:01 cole21771

I could take a wack at this. @andrewseguin do team members have objections outside contributors taking this on? I'll try to follow patterns laid out by @crisbeto . I'm planning on grabbing the drag events using the dragRef similar to how the drag.ts directive is, then use those events to resize.

nayfin avatar Feb 06 '19 04:02 nayfin

@nayfin Take a look at their contribution guide. Looks like they are happy to accept contributions, you just need to follow their guidelines outlined on that page.

Also, I really appreciate you taking this on. I'd be glad to do some testing with it once you're done or to give feedback on design choices if you'd like. I'm not an expert in Angular material, but I know some things I'd like out of the feature.

cole21771 avatar Feb 06 '19 05:02 cole21771

@cole21771 , the team usually limits outside contribution on features that need special design consideration, so it is generally a good idea to get confirmation that they are open to outside work for a particular feature before spending a lot of time developing, only to find they developed another solution internally. I will admit that this would be a bigger ticket for me, but there are already a lot of good patterns in place so I think that I can build it in a way that is consistent with the rest of the API.

Also, I will have limited free time for the foreseeable future so I will only be able to peck at it over the next few weeks, and there is a lot of source code I'll need to digest before starting. Keep this in mind if it is a feature you need soon.

nayfin avatar Feb 06 '19 17:02 nayfin

This would be awesome. I would love to help in any way.

zbennett10 avatar Feb 19 '19 18:02 zbennett10

yes yes yes xD, please I thought I'm the only one

Succubussix avatar Feb 27 '19 15:02 Succubussix

I would be very happy to work on this feature.

namangupta01 avatar Mar 01 '19 07:03 namangupta01

I'd be really glad to try to work on this as well!

pmarcanol avatar Apr 01 '19 18:04 pmarcanol

I've looked into the source quite a bit, and it will be a non-trivial feature to implement and require some design docs to be written to account for the important scenarios.

  • For drag-item resizing it will have to hook into and update the position of the drag item when resizing up or left
  • For a list of drag-items it will have to be able to do the same thing, and also might need to update positions of all items that would be affected by the resize. (Imagine a vertical list where the first item is resized to be taller, all items below would need to move down as well)
  • Would it need to handle non-drag items? I could argue both ways on this one, maybe initially only handling drag items would be best.

Additionally, all the drag events would be handy to have to make use of for this feature, but in the current implementation there doesn't seem to be a way to access the events without bringing along the drag behavior. For example: when dragging, the logic waits for dragStart event, then adjusts the position of the dragged item to correspond with the position of the pointer. For resizing we would want to hook Into those same drag events but adjust our behaviour based on what part of the element was dragged. We would only adjust position of the element when resizing the top border of the element up, or the left border towards the left, otherwise we would only be adjusting the height and/or width of the component. There is already an issue open to enable similar access to drop events for the drop-list, #14261. Hopefully, we could get a similar API setup for the drag events.

I'm happy to elaborate for anyone considering tackling this issue, as I have a need for this feature as well. Unfortunately, in its current form it would be hard to add this feature to API without inundating it with conditional logic, and repeating a lot of the event related code.

nayfin avatar Apr 01 '19 20:04 nayfin

Related: #7940

jorroll avatar May 08 '19 19:05 jorroll

Is this feature being added anytime soon?

hijazikaram avatar Jun 24 '19 20:06 hijazikaram

Any news on this?

carmo-evan avatar Jan 29 '20 18:01 carmo-evan

An Angular native feature like this would be great!

JohnnyDevNull avatar Jan 29 '20 19:01 JohnnyDevNull

bump, there is someone who wants to implement?

pontino avatar Apr 16 '20 00:04 pontino

Yeah, that would be awesome. Does anyone want to implement this?

andrisole92 avatar May 24 '20 02:05 andrisole92

Very important feature.

Ortega-Dan avatar Jul 29 '20 17:07 Ortega-Dan

would love to have this

shameersalim avatar Feb 07 '21 04:02 shameersalim

Are there any drawbacks by using https://developer.mozilla.org/en-US/docs/Web/CSS/resize ?

AntonyChiossi avatar Feb 18 '21 09:02 AntonyChiossi

I might be mistaken but I think the regular CSS resize doesn't work on elements with cdkDrag - I think that is the motivation for this feature if I am not mistaken.

Senjiu avatar Apr 23 '21 10:04 Senjiu

For anyone wondering how to use resizable behaviour alongside draggable, feel free to use (or extend) my simple solution: https://stackblitz.com/edit/angular-ivy-utqoca?file=src%2Fapp%2Fapp.component.html

image

griga avatar Nov 21 '21 13:11 griga

Still no update? Is there any Ng libs?

Lonli-Lokli avatar Mar 19 '22 23:03 Lonli-Lokli

Any updates?

ShilvantM avatar Dec 27 '23 09:12 ShilvantM

Screen Recording 2023-12-29 at 4 08 06 PM https://stackblitz.com/edit/sq7qd3?file=src%2Fexample%2Fcdk-drag-drop-boundary-example.html

Hi I added a custom directive for cdkDrag with resize functionality.

PS - Can be improved by adding transitions

ShilvantM avatar Dec 28 '23 10:12 ShilvantM

I think angular component team is not interested in angular new components or CDKs. And this reflects in recent years. And this issue is open since Jan 2019 and angular component team doesn't even bother to reply.

Wasayit avatar Apr 14 '24 21:04 Wasayit