Skip to content

Commit

Permalink
Merge pull request #101 from vadimuz/nano
Browse files Browse the repository at this point in the history
Nano image
  • Loading branch information
benhowell authored Sep 30, 2018
2 parents 65e4626 + 82e2684 commit a0d0ecb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ src | string | undefined | Required. A string ref
thumbnail | string | undefined | Required. A string referring to any valid image resource (file, url, etc).
thumbnailWidth | number | undefined | Required. Width of the thumbnail image.
thumbnailHeight | number | undefined | Required. Height of the thumbnail image.
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.
alt | string | "" | Optional. Image alt attribute.
tags | array | undefined | Optional. An array of objects containing tag attributes (value and title). e.g. `{value: "foo", title: "bar"}`
isSelected | bool | undefined | Optional. The selected state of the image.
Expand Down
1 change: 1 addition & 0 deletions src/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ Gallery.propTypes = {
images: PropTypes.arrayOf(
PropTypes.shape({
src: PropTypes.string.isRequired,
nano: PropTypes.string,
alt: PropTypes.string,
thumbnail: PropTypes.string.isRequired,
srcset: PropTypes.array,
Expand Down
20 changes: 14 additions & 6 deletions src/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ class Image extends Component {
tileViewportStyle () {
if (this.props.tileViewportStyle)
return this.props.tileViewportStyle.call(this);
var nanoBase64Backgorund = {}
if(this.props.item.nano) {
nanoBase64Backgorund = {
background: `url(${this.props.item.nano})`,
backgroundSize: 'cover',
backgroundPosition: 'center center'
}
}
if (this.props.item.isSelected)
return {
return Object.assign({
width: this.props.item.vwidth -32,
height: this.props.height -32,
margin: 16,
overflow: "hidden"
};
return {
overflow: "hidden",
}, nanoBase64Backgorund);
return Object.assign({
width: this.props.item.vwidth,
height: this.props.height,
overflow: "hidden"
};
overflow: "hidden",
}, nanoBase64Backgorund);
}

thumbnailStyle () {
Expand Down

0 comments on commit a0d0ecb

Please sign in to comment.