Comments (15)
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)
- Set allowSelect to false
- 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.
+1
from jcrop.
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.
Thanx, it helped
from jcrop.
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.
@tapmodo, thank you!
from jcrop.
@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.
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.
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.
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.
@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.
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.
Agreed, should be fixed. Also, the workaround prevents the release() API from working properly (which I need).
from jcrop.
+1
from jcrop.
+1
from jcrop.
Related Issues (20)
- I want to learn how to do a cropping plugin myself
- How can I specify a minimum width and height for cropping? HOT 2
- On Create Event Handler
- Merge showcoords and updatepreview
- The problem with calling the setImage() method with file uploaded images out of whack with the instance width and height
- Is there an option to change the image selection area to be circular
- Firefox 86.0.1 - Problem with Cropping
- Quickstart docs for jQuery not available HOT 4
- How to save cropped image to to jpg or Data URI? HOT 2
- 请提供react-jcrop版本呗
- Это дерьмо не работает. Не тратьте свое время HOT 1
- Options aren't documented
- Can you please help publish 2.0.X version to npm
- npm package is on 3.0.1
- jcrop.newCropper is not a function HOT 2
- trueSize or min, maxsize not working for large image
- Is this project maintained? HOT 1
- Broken example on jcrop.com due to wrong event name
- White image in the canva.
- Hello, if the picture is relatively large, how to get the coordinates of equal width?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jcrop.