Skip to content

Commit 8fb8708

Browse files
author
ben
committed
v0.4.0
1 parent 747be27 commit 8fb8708

File tree

5 files changed

+51
-26
lines changed

5 files changed

+51
-26
lines changed

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# react-grid-gallery
22

3+
### v0.4.0 / 2017-06-29
4+
5+
* Added optional `tileViewportStyle` prop as a function to determine style of tile viewport. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
6+
7+
* Added optional `thumbnailStyle` prop as a function to determine style of each gallery thumbnail. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
8+
9+
* Refactored implementation of `onSelectImage` prop. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
10+
11+
* Refactored implementation of `onClickThumbnail` prop. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
12+
13+
* Refactored implementation of `lightboxWillOpen` prop. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
14+
15+
* Refactored implementation of `lightboxWillClose` prop. This function leverages [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
16+
17+
18+
### v0.3.7 / 2017-06-26
19+
20+
* Added optional `tagStyle` prop to style thumbnail tags.
21+
22+
323
### v0.3.6 / 2017-06-07
424

525
* Added optional lightbox prop `showLightboxThumbnails` to display thumbnails beneath the Lightbox image.

lib/Gallery.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var Gallery = function (_Component) {
9393
event.preventDefault();
9494
}
9595
if (this.props.lightboxWillOpen) {
96-
this.props.lightboxWillOpen(index);
96+
this.props.lightboxWillOpen.call(this, index);
9797
}
9898

9999
this.setState({
@@ -105,7 +105,7 @@ var Gallery = function (_Component) {
105105
key: 'closeLightbox',
106106
value: function closeLightbox() {
107107
if (this.props.lightboxWillClose) {
108-
this.props.lightboxWillClose();
108+
this.props.lightboxWillClose.call(this);
109109
}
110110

111111
this.setState({
@@ -137,7 +137,7 @@ var Gallery = function (_Component) {
137137
key: 'onSelectImage',
138138
value: function onSelectImage(index, event) {
139139
event.preventDefault();
140-
if (this.props.onSelectImage) this.props.onSelectImage(index, this.state.images[index]);
140+
if (this.props.onSelectImage) this.props.onSelectImage.call(this, index, this.state.images[index]);
141141
}
142142
}, {
143143
key: 'gotoImage',
@@ -283,7 +283,9 @@ var Gallery = function (_Component) {
283283
isSelectable: _this2.props.enableImageSelection,
284284
onClick: _this2.getOnClickThumbnailFn(),
285285
onSelectImage: _this2.onSelectImage,
286-
tagStyle: _this2.props.tagStyle
286+
tagStyle: _this2.props.tagStyle,
287+
tileViewportStyle: _this2.props.tileViewportStyle,
288+
thumbnailStyle: _this2.props.thumbnailStyle
287289
});
288290
});
289291

@@ -359,6 +361,7 @@ Gallery.propTypes = {
359361
showImageCount: _propTypes2.default.bool,
360362
lightboxWidth: _propTypes2.default.number,
361363
tileViewportStyle: _propTypes2.default.func,
364+
thumbnailStyle: _propTypes2.default.func,
362365
showLightboxThumbnails: _propTypes2.default.bool,
363366
onClickLightboxThumbnail: _propTypes2.default.func,
364367
tagStyle: _propTypes2.default.object

lib/Image.js

+20-18
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ var Image = function (_Component) {
4141
}
4242

4343
_createClass(Image, [{
44-
key: 'tileViewportStyle',
45-
value: function tileViewportStyle() {
46-
if (this.props.item.isSelected) return {
47-
width: this.props.item.vwidth - 32,
48-
height: this.props.height - 32,
49-
margin: 16,
50-
overflow: "hidden"
51-
};
52-
return {
53-
width: this.props.item.vwidth,
54-
height: this.props.height,
55-
overflow: "hidden"
56-
};
57-
}
58-
}, {
5944
key: 'tagStyle',
6045
value: function tagStyle() {
6146
if (this.props.tagStyle) return this.props.tagStyle;
@@ -73,9 +58,26 @@ var Image = function (_Component) {
7358
borderRadius: ".25em"
7459
};
7560
}
61+
}, {
62+
key: 'tileViewportStyle',
63+
value: function tileViewportStyle() {
64+
if (this.props.tileViewportStyle) return this.props.tileViewportStyle.call(this);
65+
if (this.props.item.isSelected) return {
66+
width: this.props.item.vwidth - 32,
67+
height: this.props.height - 32,
68+
margin: 16,
69+
overflow: "hidden"
70+
};
71+
return {
72+
width: this.props.item.vwidth,
73+
height: this.props.height,
74+
overflow: "hidden"
75+
};
76+
}
7677
}, {
7778
key: 'thumbnailStyle',
7879
value: function thumbnailStyle() {
80+
if (this.props.thumbnailStyle) return this.props.thumbnailStyle.call(this);
7981
if (this.props.item.isSelected) {
8082
var ratio = this.props.item.scaletwidth / this.props.height;
8183
var height = 0;
@@ -127,7 +129,6 @@ var Image = function (_Component) {
127129
value: function render() {
128130
var _this2 = this;
129131

130-
var self = this;
131132
var tags = typeof this.props.item.tags === 'undefined' ? _react2.default.createElement('noscript', null) : this.props.item.tags.map(function (tag) {
132133
return _react2.default.createElement(
133134
'div',
@@ -139,7 +140,7 @@ var Image = function (_Component) {
139140
margin: "2px" } },
140141
_react2.default.createElement(
141142
'span',
142-
{ style: self.tagStyle() },
143+
{ style: _this2.tagStyle() },
143144
tag.value
144145
)
145146
);
@@ -216,7 +217,7 @@ var Image = function (_Component) {
216217
style: this.tileViewportStyle(),
217218
key: "tile-viewport-" + this.props.index,
218219
onClick: this.props.onClick ? function (e) {
219-
return _this2.props.onClick(_this2.props.index, e);
220+
return _this2.props.onClick.call(_this2, _this2.props.index, e);
220221
} : null },
221222
_react2.default.createElement('img', {
222223
key: "img-" + this.props.index,
@@ -239,6 +240,7 @@ Image.propTypes = {
239240
onClick: _propTypes2.default.func,
240241
onSelectImage: _propTypes2.default.func,
241242
tileViewportStyle: _propTypes2.default.func,
243+
thumbnailStyle: _propTypes2.default.func,
242244
tagStyle: _propTypes2.default.object,
243245
customOverlay: _propTypes2.default.element
244246
};

lib/react-grid-gallery.bundle.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-grid-gallery",
3-
"version": "0.3.6",
3+
"version": "0.4.0",
44
"description": "Justified gallery component for React.",
55
"main": "lib/Gallery.js",
66
"dependencies": {

0 commit comments

Comments
 (0)