Skip to content

feat: allow component to have a lock ratio - #6814

Open
UnderKoen wants to merge 1 commit into
GrapesJS:devfrom
Print-one:lock-ratio
Open

feat: allow component to have a lock ratio#6814
UnderKoen wants to merge 1 commit into
GrapesJS:devfrom
Print-one:lock-ratio

Conversation

@UnderKoen

Copy link
Copy Markdown
Contributor

Add an option to resize options that allows the component to keep it's ratio.

This disables the shift behaviour and adds the ratio keeping to the center resize handles.

I was thinking maybe this should have multiple modes that would allow shift resize

Or be split in 2 seprate options like allowShiftRatioUnlock, enforceCenterRatio

@artf

artf commented Aug 25, 2026

Copy link
Copy Markdown
Member

Make sense, but ratioLock feels too close to ratioDefault and ends up mixing a few separate behaviors into one boolean.

I wonder if it would make sense to add a new option as a function instead (eg. keepRatio) to give more flexibility

resizable: {
  keepRatio: ({ handle, shiftKey }) => {
    if (['cl', 'cr', 'tc', 'bc'].includes(handle)) return true;
    return !shiftKey;
  },
}

wdyt?

@UnderKoen

Copy link
Copy Markdown
Contributor Author

Maybe a mix?

type keepRatio = 'ALWAYS' | 'NEVER' | 'DEFAULT' | (...) => boolean;

@artf

artf commented Aug 25, 2026

Copy link
Copy Markdown
Member

That makes more sense to me. My only doubt is DEFAULT: would it actually mean anything different from leaving the option unset/undefined?

@UnderKoen

Copy link
Copy Markdown
Contributor Author

Didnt really know how to name it, as it would also be weird to have no explicit option for the default behavior.

Maybe LOOSE

@artf

artf commented Aug 26, 2026

Copy link
Copy Markdown
Member

I'd prefer to have keepRatio simply undefined to indicate "default" behavior

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

Successfully merging this pull request may close these issues.

2 participants