Skip to content

Commit a0d0ecb

Browse files
authored
Merge pull request #101 from vadimuz/nano
Nano image
2 parents 65e4626 + 82e2684 commit a0d0ecb

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ src | string | undefined | Required. A string ref
6666
thumbnail | string | undefined | Required. A string referring to any valid image resource (file, url, etc).
6767
thumbnailWidth | number | undefined | Required. Width of the thumbnail image.
6868
thumbnailHeight | number | undefined | Required. Height of the thumbnail image.
69+
nano | string:base64 | undefined | Optional. Thumbnail Base64 image will be injected to background under the main image, that is waiting for a loading. This is super helpful and fancy if you receive base64 images 4x4 pixels from the server-side response.
6970
alt | string | "" | Optional. Image alt attribute.
7071
tags | array | undefined | Optional. An array of objects containing tag attributes (value and title). e.g. `{value: "foo", title: "bar"}`
7172
isSelected | bool | undefined | Optional. The selected state of the image.

src/Gallery.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ Gallery.propTypes = {
313313
images: PropTypes.arrayOf(
314314
PropTypes.shape({
315315
src: PropTypes.string.isRequired,
316+
nano: PropTypes.string,
316317
alt: PropTypes.string,
317318
thumbnail: PropTypes.string.isRequired,
318319
srcset: PropTypes.array,

src/Image.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,26 @@ class Image extends Component {
3232
tileViewportStyle () {
3333
if (this.props.tileViewportStyle)
3434
return this.props.tileViewportStyle.call(this);
35+
var nanoBase64Backgorund = {}
36+
if(this.props.item.nano) {
37+
nanoBase64Backgorund = {
38+
background: `url(${this.props.item.nano})`,
39+
backgroundSize: 'cover',
40+
backgroundPosition: 'center center'
41+
}
42+
}
3543
if (this.props.item.isSelected)
36-
return {
44+
return Object.assign({
3745
width: this.props.item.vwidth -32,
3846
height: this.props.height -32,
3947
margin: 16,
40-
overflow: "hidden"
41-
};
42-
return {
48+
overflow: "hidden",
49+
}, nanoBase64Backgorund);
50+
return Object.assign({
4351
width: this.props.item.vwidth,
4452
height: this.props.height,
45-
overflow: "hidden"
46-
};
53+
overflow: "hidden",
54+
}, nanoBase64Backgorund);
4755
}
4856

4957
thumbnailStyle () {

0 commit comments

Comments
 (0)