Skip to content

Commit 2b1cf0f

Browse files
author
Jack Rimell
committed
fixed resize styling & opted for width/height instead of w/h
1 parent eebca62 commit 2b1cf0f

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Docs/Api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ It takes x and y coordinates and a width and height.
5252

5353
**Type** - `object`
5454

55-
**Default** - `{ w: AUTO, h: AUTO, x: 0, y: 0 }`
55+
**Default** - `{ width: AUTO, height: AUTO, x: 0, y: 0 }`
5656

5757
**Example** -
5858

src/utils/getDimensions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let getSize = (props, original, attr) => {
22
if (props.resize !== undefined) return props.resize[attr];
3+
if (props.crop !== undefined) return props.crop[attr];
34
if (props.contain !== undefined) return props.contain[attr];
45
if (props.cover !== undefined) return props.cover[attr];
56
if (props.scaleToFit !== undefined) return props.scaleToFit[attr];

src/utils/options.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ function processImage(image, props, ROOT) {
103103
: image.pass(image);
104104
};
105105

106+
image.__proto__.cropImage = function(image, crop) {
107+
return crop !== undefined
108+
? image.crop(
109+
setter(crop.x, AUTOMEASURE),
110+
setter(crop.y, AUTOMEASURE),
111+
setter(crop.width, 0),
112+
setter(crop.height, 0)
113+
)
114+
: image.pass(image);
115+
};
116+
106117
image.__proto__.changeImageQuality = function(image, quality) {
107118
return changeImageAppearence(quality, image, 'quality');
108119
};
@@ -159,17 +170,6 @@ function processImage(image, props, ROOT) {
159170
: image.pass(image);
160171
};
161172

162-
image.__proto__.cropImage = function(image, crop) {
163-
return crop !== undefined
164-
? image.crop(
165-
setter(crop.x, 0),
166-
setter(crop.y, 0),
167-
setter(crop.w, 0),
168-
setter(crop.h, 0)
169-
)
170-
: image.pass(image);
171-
};
172-
173173
image.__proto__.changeBrightness = function(image, brightness) {
174174
return changeImageAppearence(brightness, image, 'brightness');
175175
};

0 commit comments

Comments
 (0)