Skip to content

Commit b1930c8

Browse files
committed
Updated cropperjs version
1 parent 7bde5a6 commit b1930c8

File tree

4 files changed

+62
-53
lines changed

4 files changed

+62
-53
lines changed

VERSIONS.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
| Gem | Cropper.js | jQuery Cropper |
44
|--------|------------|----------------|
5+
| 1.1.1 | 1.5.9 | 1.0.1 |
56
| 1.1.0 | 1.5.6 | 1.0.1 |
67
| 1.0.2 | 1.4.3 | 1.0.0 |
78
| 1.0.1 | 1.4.2 | 1.0.0 |

lib/cropper_rails/version.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Cropper
22
module Rails
3-
VERSION = '1.1.0'.freeze
4-
CROPPER_VERSION = '1.5.6'.freeze
3+
VERSION = '1.1.1'.freeze
4+
CROPPER_VERSION = '1.5.9'.freeze
55
JQUERY_CROPPER_VERSION = '1.0.1'.freeze
66
end
77
end

vendor/assets/javascripts/cropper.js

+57-49
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/*!
2-
* Cropper.js v1.5.6
2+
* Cropper.js v1.5.9
33
* https://fengyuanchen.github.io/cropperjs
44
*
55
* Copyright 2015-present Chen Fengyuan
66
* Released under the MIT license
77
*
8-
* Date: 2019-10-04T04:33:48.372Z
8+
* Date: 2020-09-10T13:16:26.743Z
99
*/
1010

1111
(function (global, factory) {
1212
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
1313
typeof define === 'function' && define.amd ? define(factory) :
14-
(global = global || self, global.Cropper = factory());
15-
}(this, function () { 'use strict';
14+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Cropper = factory());
15+
}(this, (function () { 'use strict';
1616

1717
function _typeof(obj) {
18+
"@babel/helpers - typeof";
19+
1820
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1921
_typeof = function (obj) {
2022
return typeof obj;
@@ -84,13 +86,13 @@
8486
var source = arguments[i] != null ? arguments[i] : {};
8587

8688
if (i % 2) {
87-
ownKeys(source, true).forEach(function (key) {
89+
ownKeys(Object(source), true).forEach(function (key) {
8890
_defineProperty(target, key, source[key]);
8991
});
9092
} else if (Object.getOwnPropertyDescriptors) {
9193
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9294
} else {
93-
ownKeys(source).forEach(function (key) {
95+
ownKeys(Object(source)).forEach(function (key) {
9496
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9597
});
9698
}
@@ -100,28 +102,41 @@
100102
}
101103

102104
function _toConsumableArray(arr) {
103-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
105+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
104106
}
105107

106108
function _arrayWithoutHoles(arr) {
107-
if (Array.isArray(arr)) {
108-
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
109-
110-
return arr2;
111-
}
109+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
112110
}
113111

114112
function _iterableToArray(iter) {
115-
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
113+
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
114+
}
115+
116+
function _unsupportedIterableToArray(o, minLen) {
117+
if (!o) return;
118+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
119+
var n = Object.prototype.toString.call(o).slice(8, -1);
120+
if (n === "Object" && o.constructor) n = o.constructor.name;
121+
if (n === "Map" || n === "Set") return Array.from(o);
122+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
123+
}
124+
125+
function _arrayLikeToArray(arr, len) {
126+
if (len == null || len > arr.length) len = arr.length;
127+
128+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
129+
130+
return arr2;
116131
}
117132

118133
function _nonIterableSpread() {
119-
throw new TypeError("Invalid attempt to spread non-iterable instance");
134+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
120135
}
121136

122137
var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
123138
var WINDOW = IS_BROWSER ? window : {};
124-
var IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
139+
var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
125140
var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
126141
var NAMESPACE = 'cropper'; // Actions
127142

@@ -242,8 +257,8 @@
242257
minCanvasHeight: 0,
243258
minCropBoxWidth: 0,
244259
minCropBoxHeight: 0,
245-
minContainerWidth: 200,
246-
minContainerHeight: 100,
260+
minContainerWidth: MIN_CONTAINER_WIDTH,
261+
minContainerHeight: MIN_CONTAINER_HEIGHT,
247262
// Shortcuts of events
248263
ready: null,
249264
cropstart: null,
@@ -386,7 +401,7 @@
386401
var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
387402
/**
388403
* Normalize decimal number.
389-
* Check out {@link http://0.30000000000000004.com/}
404+
* Check out {@link https://0.30000000000000004.com/}
390405
* @param {number} value - The value to normalize.
391406
* @param {number} [times=100000000000] - The times for normalizing.
392407
* @returns {number} Returns the normalized number.
@@ -791,7 +806,7 @@
791806
function getMaxZoomRatio(pointers) {
792807
var pointers2 = _objectSpread2({}, pointers);
793808

794-
var ratios = [];
809+
var maxRatio = 0;
795810
forEach(pointers, function (pointer, pointerId) {
796811
delete pointers2[pointerId];
797812
forEach(pointers2, function (pointer2) {
@@ -802,13 +817,13 @@
802817
var z1 = Math.sqrt(x1 * x1 + y1 * y1);
803818
var z2 = Math.sqrt(x2 * x2 + y2 * y2);
804819
var ratio = (z2 - z1) / z1;
805-
ratios.push(ratio);
820+
821+
if (Math.abs(ratio) > Math.abs(maxRatio)) {
822+
maxRatio = ratio;
823+
}
806824
});
807825
});
808-
ratios.sort(function (a, b) {
809-
return Math.abs(a) < Math.abs(b);
810-
});
811-
return ratios[0];
826+
return maxRatio;
812827
}
813828
/**
814829
* Get a pointer from an event object.
@@ -1187,8 +1202,6 @@
11871202
case 8:
11881203
rotate = -90;
11891204
break;
1190-
1191-
default:
11921205
}
11931206

11941207
return {
@@ -1214,11 +1227,13 @@
12141227
options = this.options,
12151228
container = this.container,
12161229
cropper = this.cropper;
1230+
var minWidth = Number(options.minContainerWidth);
1231+
var minHeight = Number(options.minContainerHeight);
12171232
addClass(cropper, CLASS_HIDDEN);
12181233
removeClass(element, CLASS_HIDDEN);
12191234
var containerData = {
1220-
width: Math.max(container.offsetWidth, Number(options.minContainerWidth) || 200),
1221-
height: Math.max(container.offsetHeight, Number(options.minContainerHeight) || 100)
1235+
width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH),
1236+
height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT)
12221237
};
12231238
this.containerData = containerData;
12241239
setStyle(cropper, {
@@ -1259,14 +1274,15 @@
12591274
width: canvasWidth,
12601275
height: canvasHeight
12611276
};
1262-
canvasData.left = (containerData.width - canvasWidth) / 2;
1263-
canvasData.top = (containerData.height - canvasHeight) / 2;
1264-
canvasData.oldLeft = canvasData.left;
1265-
canvasData.oldTop = canvasData.top;
12661277
this.canvasData = canvasData;
12671278
this.limited = viewMode === 1 || viewMode === 2;
12681279
this.limitCanvas(true, true);
1269-
this.initialImageData = assign({}, imageData);
1280+
canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
1281+
canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
1282+
canvasData.left = (containerData.width - canvasData.width) / 2;
1283+
canvasData.top = (containerData.height - canvasData.height) / 2;
1284+
canvasData.oldLeft = canvasData.left;
1285+
canvasData.oldTop = canvasData.top;
12701286
this.initialCanvasData = assign({}, canvasData);
12711287
},
12721288
limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
@@ -1793,16 +1809,13 @@
17931809

17941810
var handlers = {
17951811
resize: function resize() {
1796-
var options = this.options,
1797-
container = this.container,
1798-
containerData = this.containerData;
1799-
var minContainerWidth = Number(options.minContainerWidth) || MIN_CONTAINER_WIDTH;
1800-
var minContainerHeight = Number(options.minContainerHeight) || MIN_CONTAINER_HEIGHT;
1801-
1802-
if (this.disabled || containerData.width <= minContainerWidth || containerData.height <= minContainerHeight) {
1812+
if (this.disabled) {
18031813
return;
18041814
}
18051815

1816+
var options = this.options,
1817+
container = this.container,
1818+
containerData = this.containerData;
18061819
var ratio = container.offsetWidth / containerData.width; // Resize when width changed or height changed
18071820

18081821
if (ratio !== 1 || container.offsetHeight !== containerData.height) {
@@ -2050,8 +2063,6 @@
20502063
}
20512064

20522065
break;
2053-
2054-
default:
20552066
}
20562067
};
20572068

@@ -2416,8 +2427,6 @@
24162427
}
24172428

24182429
break;
2419-
2420-
default:
24212430
}
24222431

24232432
if (renderable) {
@@ -3199,9 +3208,7 @@
31993208

32003209
var AnotherCropper = WINDOW.Cropper;
32013210

3202-
var Cropper =
3203-
/*#__PURE__*/
3204-
function () {
3211+
var Cropper = /*#__PURE__*/function () {
32053212
/**
32063213
* Create a new Cropper.
32073214
* @param {Element} element - The target element for cropping.
@@ -3250,7 +3257,7 @@
32503257

32513258
if (!url) {
32523259
return;
3253-
} // e.g.: "http://example.com/img/picture.jpg"
3260+
} // e.g.: "https://example.com/img/picture.jpg"
32543261

32553262

32563263
url = element.src;
@@ -3424,6 +3431,7 @@
34243431
naturalHeight: naturalHeight,
34253432
aspectRatio: naturalWidth / naturalHeight
34263433
});
3434+
_this2.initialImageData = assign({}, _this2.imageData);
34273435
_this2.sizing = false;
34283436
_this2.sized = true;
34293437

@@ -3613,4 +3621,4 @@
36133621

36143622
return Cropper;
36153623

3616-
}));
3624+
})));

vendor/assets/stylesheets/cropper.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*!
2-
* Cropper.js v1.5.6
2+
* Cropper.js v1.5.9
33
* https://fengyuanchen.github.io/cropperjs
44
*
55
* Copyright 2015-present Chen Fengyuan
66
* Released under the MIT license
77
*
8-
* Date: 2019-10-04T04:33:44.164Z
8+
* Date: 2020-09-10T13:16:21.689Z
99
*/
1010

1111
.cropper-container {

0 commit comments

Comments
 (0)