I've spent two weeks trying to implement the interaction logic for a cropper from scratch, ended up much where you are, and finally decided to just reference your implementation, which is the first and only web-based cropper I've seen that doesn't have any "weird" behavior.
Well, almost. I discovered just one minor interaction bug:
Here I'm dragging the north edge quickly towards north - notice what happens to the bottom edge of the frame? I think you're trying to reject this in calcPosition() with return false, but it happens one frame too late, after the change has already happened. To reproduce this issue, drag quickly - dragging slowly typically causes the bottom edge to be off only by one or two pixels, you might not notice.
I have no idea how to fix this, and suspect it'll require an entirely different design, which is where I've ended up dozens of times while trying to implement this myself. But at this point, I've resigned myself to the attitude of "meh, good enough" - so I completely understand if you don't want to fix this, and, either way, good job! Definitely the closest thing I've seen to a perfect cropper in JS. So thanks! :-)
I've spent two weeks trying to implement the interaction logic for a cropper from scratch, ended up much where you are, and finally decided to just reference your implementation, which is the first and only web-based cropper I've seen that doesn't have any "weird" behavior.
Well, almost. I discovered just one minor interaction bug:
Here I'm dragging the north edge quickly towards north - notice what happens to the bottom edge of the frame? I think you're trying to reject this in
calcPosition()
withreturn false
, but it happens one frame too late, after the change has already happened. To reproduce this issue, drag quickly - dragging slowly typically causes the bottom edge to be off only by one or two pixels, you might not notice.I have no idea how to fix this, and suspect it'll require an entirely different design, which is where I've ended up dozens of times while trying to implement this myself. But at this point, I've resigned myself to the attitude of "meh, good enough" - so I completely understand if you don't want to fix this, and, either way, good job! Definitely the closest thing I've seen to a perfect cropper in JS. So thanks! :-)