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

resizeGroup not honoring snapThreshold (choppy resize of selected elements) #961

Closed
davidalejandroaguilar opened this issue Jun 28, 2023 · 4 comments
Labels
bug Something isn't working complete

Comments

@davidalejandroaguilar
Copy link

davidalejandroaguilar commented Jun 28, 2023

Environments

Description

When resizing grouped elements, the width and height coming on the events do not honor snapThreshold.

On the video below (and on the codepen above), you can see that each individual item can be resized in increments of 50px.

However, when you select both items and resize, it gets choppy.

Screen.Recording.2023-06-27.at.11.38.15.p.m.mov
@davidalejandroaguilar davidalejandroaguilar changed the title resizeGroup not honoring snapThreshold (choppy group resize) resizeGroup not honoring snapThreshold (choppy resize of selected elements) Jun 28, 2023
@daybrush daybrush added checking bug Something isn't working WIP-complete and removed checking labels Jun 29, 2023
daybrush added a commit that referenced this issue Jul 2, 2023
@daybrush
Copy link
Owner

daybrush commented Jul 2, 2023

@davidalejandroaguilar

  • croact-moveable 0.6.1
  • @moveable/helper 0.1.3
  • lit-moveable 0.27.1
  • moveable 0.50.1
  • preact-moveable 0.52.1
  • react-moveable 0.53.1
  • svelte-moveable 0.42.1
  • vue-moveable 2.0.0-beta.80
  • vue3-moveable 0.25.1
  • ngx-moveable 0.47.1

moveable's new version is released. Check it again.

@davidalejandroaguilar
Copy link
Author

Thanks for the prompt follow up @daybrush! The choppiness is indeed fixed 🎉 . Though I still don't think resize is working properly.

Let me know if this should be a new issue.

In this video (same Codepen), you can see that the green rectangle (the one we're using to resize the selection) scales with the grid ✅ . However, the red rectangle does not ❌ , and you end up with the red rectangle with a smaller size than 50px (the grid size).

Screen.Recording.2023-07-03.at.8.26.19.p.m.mov

Also in this other 2 videos (same Codepen), you can see how, if you select and resize a single element, you can resize it in all directions. However, when you select and resize multiple elements, this no longer becomes possible:

Resizing a single element in all directions

Screen.Recording.2023-07-03.at.8.27.01.p.m.mov

Resizing multiple elements in all directions

Screen.Recording.2023-07-03.at.8.33.37.p.m.mov

Let me know if you need more clarification and thank you again for such a wonderful library!

@daybrush
Copy link
Owner

daybrush commented Jul 5, 2023

@davidalejandroaguilar

Sorry. group has keepRatio applied and moves with snapThreshold on a group basis. So there are a lot of problems.

However, this example may be the best.

on("beforeResizeGroup", e => {
        const throttle = num => Math.round(num / 50) * 50;
        const ratio = e.boundingWidth / e.boundingHeight;

        if (ratio < 1) {
            const nextBoundingWidth = throttle(e.boundingWidth);
            const nextBoundingHeight = nextBoundingWidth / ratio;

            e.setSize([nextBoundingWidth, nextBoundingHeight]);
        } else {
            const nextBoundingHeight = throttle(e.boundingHeight);
            const nextBoundingWidth = nextBoundingHeight * ratio;

            e.setSize([nextBoundingWidth, nextBoundingHeight]);
        }

    }).

@davidalejandroaguilar
Copy link
Author

davidalejandroaguilar commented Aug 8, 2023

Thank you very much for your time, closing this since the choppy resize (original issue) has been fixed 😃

Also, thanks for the suggested code using beforeResizeGroup for the resize problem. Seems like that would be a great solution for someone that wanted to use keepRatio: true. However, I actually want keepRatio: false.

Here's the new issue I opened to talk about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working complete
Projects
None yet
Development

No branches or pull requests

2 participants