Coder Social home page Coder Social logo

Comments (5)

scottcheng avatar scottcheng commented on July 16, 2024

There is no API for listening to image repositioning at the moment. One way to get around this is to listen to mousemove event on the preview element (see here).

I'd like to understand more about your use case scenario, i.e. why do you want to get the cropped image every time it is repositioned?

from cropit.

kangafoo avatar kangafoo commented on July 16, 2024

Hi,
I am using it to let users upload their image in a registration form.
when they crop it they will need to center the image to get their desired
part of the image.

I fixed it with mouseup()

$('#imgPreview').mouseup( function () {
var value = valueAccessor();
//var image = $('#image-cropper').cropit('export');
var image = $('#image-cropper').cropit('export', {
type: 'image/jpeg',
quality: .9,
originalSize: false
});
value(image);
});
}

Thanks for the help.

On 12 September 2014 07:19, Scott Cheng [email protected] wrote:

There is no API for listening to image repositioning at the moment. One
way to get around this is to listen to mousemove event on the preview
element (see here

@$preview.on 'mousemove', @onMove.bind @

).

I'd like to understand more about your use case scenario, i.e. why do you
want to get the cropped image every time it is repositioned?


Reply to this email directly or view it on GitHub
#9 (comment).

from cropit.

scottcheng avatar scottcheng commented on July 16, 2024

I see. Are you trying to reflect the updated cropped image, e.g. show the cropped image somewhere else, every time it is repositioned? Otherwise if what you need is to pass the cropped image with the form, you only need to call export before form submission, instead of after each time the image is dragged.

Also, you may want to also listen to mouseleave, because mouseup does not get called when user moves the mouse out of the preview box whiling pressing it.

from cropit.

kangafoo avatar kangafoo commented on July 16, 2024

Hey thanks. Will add the mouseleave event as well. I call export on change
of image-cropper and update a knockout binding. The cropper seems to pick
up a change when I change the slider. However, if my last action is
dragging the image, then it does not pick it up and the submitted image is
that of the last zoomed one.

On 12 September 2014 14:08, Scott Cheng [email protected] wrote:

I see. Are you trying to reflect the updated cropped image, e.g. show the
cropped image somewhere else, every time it is repositioned? Otherwise if
what you need is to pass the cropped image with the form, you only need to
call export before form submission, instead of after each time the image
is dragged.

Also, you may want to also listen to mouseleave, because mouseup does not
get called when user moves the mouse out of the preview box whiling
pressing it.


Reply to this email directly or view it on GitHub
#9 (comment).

from cropit.

scottcheng avatar scottcheng commented on July 16, 2024

Glad to know it's working, although it still seems to me that a better solution may be to only call export right before you actually submit the form.

Regarding why change is not working, my guess is that when the slider is changed, the slider element fires a change event when then bubbles up to #image-cropper which you are then able to capture. However when the image is dragged no change event is fired anywhere.

from cropit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.