crop_your_image
crop_your_image copied to clipboard
Add bounceback zoom-out
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).
https://github.com/chooyan-eng/crop_your_image/assets/28866174/b668fe54-2421-4e46-a13c-886ee7bb2329
@ChristineWasike Thank you for your idea! It looks sweet. I'll try in the future version.