Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nano image #101

Merged
merged 2 commits into from
Sep 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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