This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Riccardo Buzzotta
Posted Jun 16 - Read on Facebook

Hi, all!

New day, new prototype:
https://framer.cloud/qdHNV

I created this super simple cropper class for a camera prototype. And I didn't spend time on creating the best code ever.

The problem I have is: why when I interact with the second handle the crop area doesn't get updated properly? Somehow the crop layer doesn't get the new width/height that was set by dragging the first handle.

4 Comments

Jonas Treub

Right now you have your logic repeated for each drag handle. Its easier to change the code if you handle it in a single place. Here I added a function named updateCrop that recalculates the crop area for each handle: https://framer.cloud/eiMGX

Riccardo Buzzotta

Thank you, Jonas Treub!
In my mind I had to start from the handles… but that updateCrop method really does the job.
Now I can polish this up and upload it to Github for further sharing. :)

Jonas Treub

Its still easy to break. To fix it you'll have to check all draghandles their positions to determine the minX, maxX, minY and maxY.

Read the entire post on Facebook