photoswipe
Cropper.js is mainly aimed at mobile
here are some of the api I have sorted out
const cropper = new Cropper(image, {
aspectRatio: 1, //
viewMode: 0, // 2 0
// preview : $(".newImg"), // :String(jQuery)''
crop: function(event) { //
console.log(event.detail.x);
console.log(event.detail.y);
console.log(event.detail.width);
console.log(event.detail.height);
cropper.getCroppedCanvas();
cropper.getCroppedCanvas({ //
width: 300,
height: 300,
minWidth: 256,
minHeight: 256,
maxWidth: 4096,
maxHeight: 4096,
fillColor: '-sharpfff',
imageSmoothingEnabled: false,
imageSmoothingQuality: 'high',
});
if (!HTMLCanvasElement.prototype.toBlob) { // toBlob
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
value: function (callback, type, quality) {
var binStr = atob( this.toDataURL(type, quality).split(',')[1] ),
len = binStr.length,
arr = new Uint8Array(len);
for (var i=0; i<len; iPP ) {
arr[i] = binStr.charCodeAt(i);
}
callback( new Blob( [arr], {type: type || 'image/png'} ) );
}
});
}
$(".img").attr("src" , cropper.getCroppedCanvas().toDataURL('image/jpeg')); // base64
// cropper.getCroppedCanvas().toBlob((blob) => {
// });
},
build: function (e) { //
//
console.log(111111111)
},
built: function (e) { //
},
checkCrossOrigin: true, //crossOrigin classurlgetCroppedCanvas
minContainerWidth: 300,
minContainerHeight:300,
minCanvasWidth: 300,
minCanvasHeight: 300,
minCropBoxWidth : 300, // :
minCropBoxHeight: 300, // :
rotatable : false , //
guides:false, // true
center: false, // true +
background : false,//
dragMode: "move", // crop 'none': do nothing 'crop': create a new crop box
modal : false, // true
cropBoxMovable :false, //
cropBoxResizable :false, //
toggleDragModeOnDblclick: false, //"" ""
});