Responsive viewport and boundary
See original GitHub issueHello everyone, I have one question is there any solution to redraw/reset the croppie boundary and viewport on window resize I tried something like this for tracking and setting new value:
var bwidth;
$(window).resize(function(){
cwidth = $(window).width();
if( cwidth <= 480 && cwidth >= 320) {
bwidth = cwidth - 40;
} else {
bwidth = 185;
}
});
and here is the config code:
$uploadCrop = $('#uploaded-picture').croppie({
enableExif: true,
viewport: {
width: 220,
height: 330
},
boundary: {
width: bwidth,
height: 411
},
enableOrientation: true
});
I only get the croppie container with 185px width.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Responsive Web Design Viewport - W3Schools
The viewport is the user's visible area of a web page. The viewport varies with the device, and will be smaller on a...
Read more >Responsive web design basics
Responsive web design basics ; Set the viewport. Ensure an accessible viewport ; Size content to the viewport. Images; Layout ; Use CSS...
Read more >Viewport concepts - CSS: Cascading Style Sheets | MDN
Any sub-viewport that is fully or partially displayed within the layout viewport is considered a visual viewport. We generally think of width ...
Read more >Viewport-relative, fluid, responsive web design
Learn how to build a viewport-relative, fluid, responsive web design using CSS. Information on the pros and cons of such a web design ......
Read more >Viewports and Media Queries - LearnHowToProgram.com
Also, keep in mind this week will focus only on implementing the media query code that make a site responsive. We won't explore...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found simpler solution. Just re-bind values on the window resize to force croppie to re-calculate values like this:
I spent a few hours trying to solve this. Making it responsive in bootstrap on an Iphone5 for example meant that any static values would overlap the screen. As I’m trying to maintain an aspect ratio (2:1 i.e. a rectangle) and maintain the margin appearance of the boundary over the viewport, I’ve set the enableResize option to false. My problem had the added complexity of this rendering in a bootstrap modal but got I there with this:
With this, what ever the size of my bootstrap modal, croppie’s dimensions are then set dynamically. The only problem I’ve got with this is that if the browser’s viewport is resized after this is executed then croppie’s width and height settings aren’t updated but guess this is easily solved with some change event, etc.