Code Monkey home page Code Monkey logo

Comments (15)

richiesun avatar richiesun commented on May 27, 2024 2

I also ran into this bug. I didn't want users selecting an image size smaller than 100x100px, but everytime a corner was dragged into the opposite corner, the selection box would disappear, but the submit would still validate as good since the hidden width and height values never went below 100 x 100 px. A disappearing selection box is very confusing for the user.

Here's my workaround: (see also https://github.com/tapmodo/Jcrop/blob/master/demos/tutorial5.html)

  1. Set allowSelect to false
  2. Add function to onRelease called releaseCheck

$('#image').Jcrop({
onSelect : updateCoords,
bgColor : 'transparent', // Allows for png's to not inherit black background
bgOpacity : .2,
setSelect : [ 0, 0, 100, 100 ],
aspectRatio : 1,
minSize : [100, 100],
allowSelect : false,
onRelease : releaseCheck
});

// This function redraws the selection box when it disappears to my original coordinates.
// Does not redraw based on last coordinates.
function releaseCheck() {
this.setOptions({ setSelect: [0,0,100,100] });
};

from jcrop.

raiika avatar raiika commented on May 27, 2024 1

+1

from jcrop.

kewh avatar kewh commented on May 27, 2024

I did this by changing line 361 from
}).mousedown(newSelection);
to
});
but I am sure it must be possible to do this via the API. Would also appreciate any ideas.

from jcrop.

jesteracer avatar jesteracer commented on May 27, 2024

Thanx, it helped

from jcrop.

tapmodo avatar tapmodo commented on May 27, 2024

Hi! Sorry it took me a couple of days to write back. Try the option allowSelect: false ... if you are using minSize/maxSize setting and aspectRatio, there is a bug which makes it possible to release the selection even though you shouldn't be able to. For this reason, if you are going to use allowSelect: false, I recommend attaching an onRelease handler that uses setSelect to reset the selection to something reasonable, to prevent users from losing the ability to select.

from jcrop.

jesteracer avatar jesteracer commented on May 27, 2024

@tapmodo, thank you!

from jcrop.

merlinrebrovic avatar merlinrebrovic commented on May 27, 2024

@tapmodo Your comment invalidated two full days of coding and debugging, but on the other hand, halved my codebase and solved an issue in a few minutes, so - thank you :) I'm referring to the undocumented options allowSelect and onRelease. They can be found through code review, but it's not always plausible to search 1500+ lines of code. Do you plan to extend the docs on the official page sometimes in the future? I'm sure it would help and save time to lots of people.

from jcrop.

tapmodo avatar tapmodo commented on May 27, 2024

Very sorry about that. I know that the posted documentation is lagging. I've been working on an updated site which has fairly complete documentation, but I've been thinking about different ways to approach it. Probably I should go and make a pass at updating the current documentation with the things that most people ask about, then continue working on the new site. The only two comments I have are: these features are evidenced in the available demos that come with Jcrop as well as the ones on the website. Additionally, onRelease has been mentioned in a blog post on the updated features of the new version, despite not being added to the documentation yet. I'm workin' on it! Thank you for your patience and support.

from jcrop.

merlinrebrovic avatar merlinrebrovic commented on May 27, 2024

I wasn't aware how really important documentation is until I started working with/at some of the open-source projects. The one that had it were taken for granted, but the one that didn't were a real pain and have little chance of catching on.

Jcrop's docs have a very good coverage, most of the things needed for standard work is there. You'll be very happy to hear that we're using Jcrop in a technologically advanced enterprise project, doing some pretty cool stuff and pushing Jcrop to the limits :) But because of that we have hit some edge cases so we needed source code review and some less know options.

I love it and think it's awesome. Keep up the good work :)

from jcrop.

rduplain avatar rduplain commented on May 27, 2024

I would prefer an allowRelease option, which disables release altogether. A naive fork would check options.allowRelease in the release() method (and set a default), but this does not prevent clearing the interface given the current implementation.

I ended up using an onRelease workaround which calls setSelection to the last known coordinates, then calls api.enable() to force an inner call to interfaceUpdate().

Thanks.

from jcrop.

danxshap avatar danxshap commented on May 27, 2024

@tapmodo or @rduplain or anyone else who may be able to help,

I need to use both minSize and aspectRatio and force my users to select a crop area (i.e. set allowSelect to false). I ran into the bug that @tapmodo described above, but I'm having trouble with the workaround.

In my onRelease function I have this.setSelect(this.tellSelect()) followed by this.enable() to try and retain the previous coordinates, but after this happens, the selection area gets locked and can't be changed/moved by the user.

Since I have allowSelect set to false, the only way this happens is if the user presses ESC on their keyboard, which releases the selection and triggers my onRelease callback as described above. I'd like to fix it so that if they press ESC, effectively nothing will happen (i.e. the crop selection doesn't go away and they can still adjust).

Any ideas? Thanks!

from jcrop.

fredw avatar fredw commented on May 27, 2024

This problem still occurs in the latest version.
This should be fixed to prevent this problem. I had a lot of headaches before finding this post about this problem.

from jcrop.

cjbottaro avatar cjbottaro commented on May 27, 2024

Agreed, should be fixed. Also, the workaround prevents the release() API from working properly (which I need).

from jcrop.

sfarthin avatar sfarthin commented on May 27, 2024

+1

from jcrop.

istvanmadarasz avatar istvanmadarasz commented on May 27, 2024

+1

from jcrop.

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.