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

Add bounceback zoom-out #119

Open
ChristineWasike opened this issue Sep 13, 2023 · 1 comment
Open

Add bounceback zoom-out #119

ChristineWasike opened this issue Sep 13, 2023 · 1 comment
Assignees
Labels
Idea Ideas for a new feature

Comments

@ChristineWasike
Copy link

It's more so for current specific needs but might also be useful to others.
The ability to zoom out on an image and have it bounce back in place to fit the specified crop area.
I have tried experimenting with the onMoved, initialArea and the cropController, but it doesn't seem to work.
I think having it as animateArea as an addition to the controller functions would do it.
Could we bake in this feature?

Here's a snippet of what I tried:

Crop(
    ...
    controller: cropController,
    initialAreaBuilder: (rect) {
      /// Save the initial cropping area
      setState(() {
        initialCroppingArea = rect;
      });
  
      return Rect.fromLTRB(
        rect.left,
        rect.top,
        rect.right,
        rect.bottom,
      );
    },
    fixArea: true,
    onMoved: (newRect) {
      // Check if the newRect is outside the boundaries
      if (newRect.left < initialCroppingArea!.left ||
          newRect.top < initialCroppingArea!.top ||
          newRect.right > initialCroppingArea!.right ||
          newRect.bottom > initialCroppingArea!.bottom) {
        // Animate back to the initial cropping area
        cropController.crop();
  
        
        // .animateArea(initialCroppingArea!, duration: 500);
        // .cropTo(initialCroppingArea);
      } else {
        // do something with current cropping area.
      }
    },
    ...
),

Here's a video of what this looks like (sourced from Instagram).

-4305794482942258531rpreplay_final1692791961.mov
@chooyan-eng
Copy link
Owner

@ChristineWasike Thank you for your idea! It looks sweet. I'll try in the future version.

@chooyan-eng chooyan-eng added the Idea Ideas for a new feature label Feb 8, 2024
@chooyan-eng chooyan-eng self-assigned this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea Ideas for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants