react-photo-gallery
Advanced tools
Comparing version 5.1.5 to 5.2.5
@@ -6,3 +6,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Gallery = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
value: true | ||
}); | ||
@@ -25,136 +25,143 @@ | ||
var Gallery = (function (_React$Component) { | ||
_inherits(Gallery, _React$Component); | ||
_inherits(Gallery, _React$Component); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
src = _this.props.photos[k].src; | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var src = _this.props.photos[k].src, | ||
srcset = undefined, | ||
sizes = undefined; | ||
if (_this.props.photos[k].srcset) { | ||
srcset = _this.props.photos[k].srcset.join(); | ||
} | ||
if (_this.props.photos[k].sizes) { | ||
sizes = _this.props.photos[k].sizes.join(); | ||
} | ||
for (var k = i; k < i + cols; k++) { | ||
var src; | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var _ret = _loop(k); | ||
for (var k = i; k < i + cols; k++) { | ||
var _ret = _loop(k); | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
return Gallery; | ||
return Gallery; | ||
})(_react2['default'].Component); | ||
@@ -165,22 +172,24 @@ | ||
Gallery.propTypes = { | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string, | ||
srcset: _react2['default'].PropTypes.array, | ||
sizes: _react2['default'].PropTypes.array | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
}; | ||
Gallery.defaultProps = { | ||
cols: 3 | ||
cols: 3 | ||
}; | ||
// Gallery image style | ||
var style = { | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
}; | ||
@@ -187,0 +196,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Gallery=e()}}(function(){return function e(t,o,r){function n(a,l){if(!o[a]){if(!t[a]){var s="function"==typeof require&&require;if(!l&&s)return s(a,!0);if(i)return i(a,!0);var p=new Error("Cannot find module '"+a+"'");throw p.code="MODULE_NOT_FOUND",p}var u=o[a]={exports:{}};t[a][0].call(u.exports,function(e){var o=t[a][1][e];return n(o?o:e)},u,u.exports,e,t,o,r)}return o[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)n(r[a]);return n}({1:[function(e,t,o){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(o,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,o,r){return o&&e(t.prototype,o),r&&e(t,r),t}}(),l=function(e,t,o){for(var r=!0;r;){var n=e,i=t,a=o;r=!1,null===n&&(n=Function.prototype);var l=Object.getOwnPropertyDescriptor(n,i);if(void 0!==l){if("value"in l)return l.value;var s=l.get;if(void 0===s)return;return s.call(a)}var p=Object.getPrototypeOf(n);if(null===p)return;e=p,t=i,o=a,r=!0,l=p=void 0}},s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,p=r(s),u=function(e){function t(){n(this,t),l(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.state={containerWidth:0},this.handleResize=this.handleResize.bind(this)}return i(t,e),a(t,[{key:"componentDidMount",value:function(){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function(){this._gallery.clientWidth!==this.state.containerWidth&&this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"handleResize",value:function(e){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"render",value:function(){var e=this,t=this.props.cols,o=[],r=this.state.containerWidth-4*t;r=Math.floor(r);var n=this.props.photos.length%t;if(n)var i=Math.floor(this.state.containerWidth/t*n-4*n),a=this.props.photos.length-n;for(var l=0;l<this.props.photos.length;l+=t){for(var s=0,u=0,d=l;d<l+t&&d!=this.props.photos.length;d++)this.props.photos[d].aspectRatio=this.props.photos[d].width/this.props.photos[d].height,s+=this.props.photos[d].aspectRatio;u=l===a?i/s:r/s;for(var c=function(t){return t==e.props.photos.length?"break":(y=e.props.photos[t].src,void(e.props.onClickPhoto?o.push(p["default"].createElement("div",{key:t,style:f},p["default"].createElement("a",{href:"#",className:t,onClick:function(o){return e.props.onClickPhoto(t,o)}},p["default"].createElement("img",{src:y,style:{display:"block",border:0},height:u,width:u*e.props.photos[t].aspectRatio,alt:e.props.photos[t].alt})))):o.push(p["default"].createElement("div",{key:t,style:f},p["default"].createElement("img",{src:y,style:{display:"block",border:0},height:u,width:u*e.props.photos[t].aspectRatio,alt:e.props.photos[t].alt})))))},h=l;h<l+t;h++){var y,v=c(h);if("break"===v)break}}return this.renderGallery(o)}},{key:"renderGallery",value:function(e){var t=this;return this.props.disableLightbox?p["default"].createElement("div",{id:"Gallery",className:"clearfix",ref:function(e){return t._gallery=e}},e):p["default"].createElement("div",{id:"Gallery",className:"clearfix",ref:function(e){return t._gallery=e}},e)}}]),t}(p["default"].Component);u.displayName="Gallery",u.propTypes={photos:function(e,t,o){return p["default"].PropTypes.arrayOf(p["default"].PropTypes.shape({src:p["default"].PropTypes.string.isRequired,width:p["default"].PropTypes.number.isRequired,height:p["default"].PropTypes.number.isRequired,alt:p["default"].PropTypes.string})).isRequired.apply(this,arguments)},onClickPhoto:p["default"].PropTypes.func,cols:p["default"].PropTypes.number},u.defaultProps={cols:3};var f={display:"block",margin:2,backgroundColor:"#e3e3e3","float":"left"};o["default"]=u,t.exports=o["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Gallery=e()}}(function(){return function e(t,o,r){function n(s,a){if(!o[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var p=new Error("Cannot find module '"+s+"'");throw p.code="MODULE_NOT_FOUND",p}var u=o[s]={exports:{}};t[s][0].call(u.exports,function(e){var o=t[s][1][e];return n(o?o:e)},u,u.exports,e,t,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(e,t,o){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(o,"__esModule",{value:!0});var s=function(){function e(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,o,r){return o&&e(t.prototype,o),r&&e(t,r),t}}(),a=function(e,t,o){for(var r=!0;r;){var n=e,i=t,s=o;r=!1,null===n&&(n=Function.prototype);var a=Object.getOwnPropertyDescriptor(n,i);if(void 0!==a){if("value"in a)return a.value;var l=a.get;if(void 0===l)return;return l.call(s)}var p=Object.getPrototypeOf(n);if(null===p)return;e=p,t=i,o=s,r=!0,a=p=void 0}},l="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,p=r(l),u=function(e){function t(){n(this,t),a(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.state={containerWidth:0},this.handleResize=this.handleResize.bind(this)}return i(t,e),s(t,[{key:"componentDidMount",value:function(){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function(){this._gallery.clientWidth!==this.state.containerWidth&&this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"handleResize",value:function(e){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"render",value:function(){var e=this,t=this.props.cols,o=[],r=this.state.containerWidth-4*t;r=Math.floor(r);var n=this.props.photos.length%t;if(n)var i=Math.floor(this.state.containerWidth/t*n-4*n),s=this.props.photos.length-n;for(var a=0;a<this.props.photos.length;a+=t){for(var l=0,u=0,c=a;c<a+t&&c!=this.props.photos.length;c++)this.props.photos[c].aspectRatio=this.props.photos[c].width/this.props.photos[c].height,l+=this.props.photos[c].aspectRatio;u=a===s?i/l:r/l;for(var d=function(t){if(t==e.props.photos.length)return"break";var r=e.props.photos[t].src,n=void 0,i=void 0;e.props.photos[t].srcset&&(n=e.props.photos[t].srcset.join()),e.props.photos[t].sizes&&(i=e.props.photos[t].sizes.join()),e.props.onClickPhoto?o.push(p["default"].createElement("div",{key:t,style:f},p["default"].createElement("a",{href:"#",className:t,onClick:function(o){return e.props.onClickPhoto(t,o)}},p["default"].createElement("img",{src:r,srcSet:n,sizes:i,style:{display:"block",border:0},height:u,width:u*e.props.photos[t].aspectRatio,alt:e.props.photos[t].alt})))):o.push(p["default"].createElement("div",{key:t,style:f},p["default"].createElement("img",{src:r,srcSet:n,sizes:i,style:{display:"block",border:0},height:u,width:u*e.props.photos[t].aspectRatio,alt:e.props.photos[t].alt})))},h=a;h<a+t;h++){var y=d(h);if("break"===y)break}}return this.renderGallery(o)}},{key:"renderGallery",value:function(e){var t=this;return this.props.disableLightbox?p["default"].createElement("div",{id:"Gallery",className:"clearfix",ref:function(e){return t._gallery=e}},e):p["default"].createElement("div",{id:"Gallery",className:"clearfix",ref:function(e){return t._gallery=e}},e)}}]),t}(p["default"].Component);u.displayName="Gallery",u.propTypes={photos:function(e,t,o){return p["default"].PropTypes.arrayOf(p["default"].PropTypes.shape({src:p["default"].PropTypes.string.isRequired,width:p["default"].PropTypes.number.isRequired,height:p["default"].PropTypes.number.isRequired,alt:p["default"].PropTypes.string,srcset:p["default"].PropTypes.array,sizes:p["default"].PropTypes.array})).isRequired.apply(this,arguments)},onClickPhoto:p["default"].PropTypes.func,cols:p["default"].PropTypes.number},u.defaultProps={cols:3};var f={display:"block",margin:2,backgroundColor:"#e3e3e3","float":"left"};o["default"]=u,t.exports=o["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); |
@@ -5,3 +5,3 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"react-photo-gallery":[function(require,module,exports){ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
value: true | ||
}); | ||
@@ -24,136 +24,143 @@ | ||
var Gallery = (function (_React$Component) { | ||
_inherits(Gallery, _React$Component); | ||
_inherits(Gallery, _React$Component); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
src = _this.props.photos[k].src; | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var src = _this.props.photos[k].src, | ||
srcset = undefined, | ||
sizes = undefined; | ||
if (_this.props.photos[k].srcset) { | ||
srcset = _this.props.photos[k].srcset.join(); | ||
} | ||
if (_this.props.photos[k].sizes) { | ||
sizes = _this.props.photos[k].sizes.join(); | ||
} | ||
for (var k = i; k < i + cols; k++) { | ||
var src; | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var _ret = _loop(k); | ||
for (var k = i; k < i + cols; k++) { | ||
var _ret = _loop(k); | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
return Gallery; | ||
return Gallery; | ||
})(_react2['default'].Component); | ||
@@ -164,22 +171,24 @@ | ||
Gallery.propTypes = { | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string, | ||
srcset: _react2['default'].PropTypes.array, | ||
sizes: _react2['default'].PropTypes.array | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
}; | ||
Gallery.defaultProps = { | ||
cols: 3 | ||
cols: 3 | ||
}; | ||
// Gallery image style | ||
var style = { | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
}; | ||
@@ -190,2 +199,3 @@ | ||
},{"react":undefined}]},{},[]); | ||
},{"react":undefined}]},{},[]) | ||
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvVXNlcnMvb2N0YXZpYS9kZXYvcmVhY3QtcGhvdG8tZ2FsbGVyeS9zcmMvR2FsbGVyeS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7cUJDQWtCLE9BQU87Ozs7SUFFbkIsT0FBTztjQUFQLE9BQU87O0FBQ0UsYUFEVCxPQUFPLEdBQ0k7OEJBRFgsT0FBTzs7QUFFWixtQ0FGSyxPQUFPLDZDQUVKO0FBQ1IsWUFBSSxDQUFDLEtBQUssR0FBRztBQUNULDBCQUFjLEVBQUUsQ0FBQztTQUNwQixDQUFDO0FBQ0YsWUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztLQUM3Qzs7aUJBUEMsT0FBTzs7ZUFRUSw2QkFBRTtBQUN0QixnQkFBSSxDQUFDLFFBQVEsQ0FBQyxFQUFDLGNBQWMsRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLEVBQUMsQ0FBQyxDQUFBO0FBQy9ELGtCQUFNLENBQUMsZ0JBQWdCLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxZQUFZLENBQUMsQ0F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OiAzXG59XG4vLyBHYWxsZXJ5IGltYWdlIHN0eWxlXG5jb25zdCBzdHlsZSA9IHtcbiAgIGRpc3BsYXk6ICdibG9jaycsXG4gICBtYXJnaW46IDIsXG4gICBiYWNrZ3JvdW5kQ29sb3I6JyNlM2UzZTMnLFxuICAgZmxvYXQ6ICdsZWZ0J1xufVxuXG5leHBvcnQgZGVmYXVsdCBHYWxsZXJ5O1xuIl19 |
@@ -6,3 +6,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Gallery = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
value: true | ||
}); | ||
@@ -25,136 +25,143 @@ | ||
var Gallery = (function (_React$Component) { | ||
_inherits(Gallery, _React$Component); | ||
_inherits(Gallery, _React$Component); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
src = _this.props.photos[k].src; | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var src = _this.props.photos[k].src, | ||
srcset = undefined, | ||
sizes = undefined; | ||
if (_this.props.photos[k].srcset) { | ||
srcset = _this.props.photos[k].srcset.join(); | ||
} | ||
if (_this.props.photos[k].sizes) { | ||
sizes = _this.props.photos[k].sizes.join(); | ||
} | ||
for (var k = i; k < i + cols; k++) { | ||
var src; | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var _ret = _loop(k); | ||
for (var k = i; k < i + cols; k++) { | ||
var _ret = _loop(k); | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
return Gallery; | ||
return Gallery; | ||
})(_react2['default'].Component); | ||
@@ -165,22 +172,24 @@ | ||
Gallery.propTypes = { | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string, | ||
srcset: _react2['default'].PropTypes.array, | ||
sizes: _react2['default'].PropTypes.array | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
}; | ||
Gallery.defaultProps = { | ||
cols: 3 | ||
cols: 3 | ||
}; | ||
// Gallery image style | ||
var style = { | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
}; | ||
@@ -187,0 +196,0 @@ |
@@ -59,3 +59,8 @@ import React from 'react'; | ||
obj.url_h+' '+obj.width_h+'w' | ||
] | ||
], | ||
sizes:[ | ||
'(min-width: 480px) 50vw', | ||
'(min-width: 1024px) 33.3vw', | ||
'100vw' | ||
] | ||
}); | ||
@@ -62,0 +67,0 @@ }) |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
value: true | ||
}); | ||
@@ -22,136 +22,143 @@ | ||
var Gallery = (function (_React$Component) { | ||
_inherits(Gallery, _React$Component); | ||
_inherits(Gallery, _React$Component); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
function Gallery() { | ||
_classCallCheck(this, Gallery); | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_get(Object.getPrototypeOf(Gallery.prototype), 'constructor', this).call(this); | ||
this.state = { | ||
containerWidth: 0 | ||
}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
_createClass(Gallery, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
window.addEventListener('resize', this.handleResize); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
window.removeEventListener('resize', this.handleResize, false); | ||
} | ||
}, { | ||
key: 'handleResize', | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this = this; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
var cols = this.props.cols, | ||
photoPreviewNodes = []; | ||
var contWidth = this.state.containerWidth - cols * 4; /* 4px for margin around each image*/ | ||
contWidth = Math.floor(contWidth); // add some padding to prevent layout prob | ||
var remainder = this.props.photos.length % cols; | ||
if (remainder) { | ||
// there are fewer photos than cols num in last row | ||
var lastRowWidth = Math.floor(this.state.containerWidth / cols * remainder - remainder * 4); | ||
var lastRowIndex = this.props.photos.length - remainder; | ||
} | ||
// loop thru each set of cols num | ||
// eg. if cols is 3 it will loop thru 0,1,2, then 3,4,5 to perform calculations for the particular set | ||
for (var i = 0; i < this.props.photos.length; i += cols) { | ||
var totalAr = 0, | ||
commonHeight = 0; | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
// get the total aspect ratio of the row | ||
for (var j = i; j < i + cols; j++) { | ||
if (j == this.props.photos.length) { | ||
break; | ||
} | ||
this.props.photos[j].aspectRatio = this.props.photos[j].width / this.props.photos[j].height; | ||
totalAr += this.props.photos[j].aspectRatio; | ||
} | ||
if (i === lastRowIndex) { | ||
commonHeight = lastRowWidth / totalAr; | ||
} else { | ||
commonHeight = contWidth / totalAr; | ||
} | ||
// run thru the same set of items again to give the width and common height | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
src = _this.props.photos[k].src; | ||
var _loop = function (k) { | ||
if (k == _this.props.photos.length) { | ||
return 'break'; | ||
} | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var src = _this.props.photos[k].src, | ||
srcset = undefined, | ||
sizes = undefined; | ||
if (_this.props.photos[k].srcset) { | ||
srcset = _this.props.photos[k].srcset.join(); | ||
} | ||
if (_this.props.photos[k].sizes) { | ||
sizes = _this.props.photos[k].sizes.join(); | ||
} | ||
for (var k = i; k < i + cols; k++) { | ||
var src; | ||
if (_this.props.onClickPhoto) { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement( | ||
'a', | ||
{ href: '#', className: k, onClick: function (e) { | ||
return _this.props.onClickPhoto(k, e); | ||
} }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
) | ||
)); | ||
} else { | ||
photoPreviewNodes.push(_react2['default'].createElement( | ||
'div', | ||
{ key: k, style: style }, | ||
_react2['default'].createElement('img', { src: src, srcSet: srcset, sizes: sizes, style: { display: 'block', border: 0 }, height: commonHeight, width: commonHeight * _this.props.photos[k].aspectRatio, alt: _this.props.photos[k].alt }) | ||
)); | ||
} | ||
}; | ||
var _ret = _loop(k); | ||
for (var k = i; k < i + cols; k++) { | ||
var _ret = _loop(k); | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (_ret === 'break') break; | ||
} | ||
} | ||
return this.renderGallery(photoPreviewNodes); | ||
} | ||
}, { | ||
key: 'renderGallery', | ||
value: function renderGallery(photoPreviewNodes) { | ||
var _this2 = this; | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
if (this.props.disableLightbox) { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} else { | ||
return _react2['default'].createElement( | ||
'div', | ||
{ id: 'Gallery', className: 'clearfix', ref: function (c) { | ||
return _this2._gallery = c; | ||
} }, | ||
photoPreviewNodes | ||
); | ||
} | ||
} | ||
}]); | ||
return Gallery; | ||
return Gallery; | ||
})(_react2['default'].Component); | ||
@@ -162,22 +169,24 @@ | ||
Gallery.propTypes = { | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
photos: function photos(props, propName, componentName) { | ||
return _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.shape({ | ||
src: _react2['default'].PropTypes.string.isRequired, | ||
width: _react2['default'].PropTypes.number.isRequired, | ||
height: _react2['default'].PropTypes.number.isRequired, | ||
alt: _react2['default'].PropTypes.string, | ||
srcset: _react2['default'].PropTypes.array, | ||
sizes: _react2['default'].PropTypes.array | ||
})).isRequired.apply(this, arguments); | ||
}, | ||
onClickPhoto: _react2['default'].PropTypes.func, | ||
cols: _react2['default'].PropTypes.number | ||
}; | ||
Gallery.defaultProps = { | ||
cols: 3 | ||
cols: 3 | ||
}; | ||
// Gallery image style | ||
var style = { | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
display: 'block', | ||
margin: 2, | ||
backgroundColor: '#e3e3e3', | ||
float: 'left' | ||
}; | ||
@@ -184,0 +193,0 @@ |
{ | ||
"name": "react-photo-gallery", | ||
"version": "5.1.5", | ||
"version": "5.2.5", | ||
"description": "Responsive React Photo Gallery Component", | ||
@@ -5,0 +5,0 @@ "main": "lib/Gallery.js", |
@@ -83,3 +83,5 @@ # React Responsive Photo Gallery | ||
:-----------------------|:--------------|:--------------|:-------------------------------- | ||
src | string | undefined | required; the src value of the gallery image | ||
src | string | undefined | required; the img src attribute value of the gallery image | ||
srcset | string | undefined | optional; the img srcset attribute value of the gallery image | ||
sizes | string | undefined | optional; the img sizes attribute value of the gallery image | ||
width | number | undefined | required; original width of the gallery image (only used for calculating aspect ratio) | ||
@@ -92,1 +94,3 @@ height | number | undefined | required; original height of the gallery image (only used for calculating aspect ratio) | ||
PHOTO_SET obj in the example above is also being passed to lightbox which uses src, srcset, and caption props. | ||
To gain a good understanding of 'srcset' and 'sizes' attributes, I found this site very helpful: [https://ericportis.com/posts/2014/srcset-sizes/](https://ericportis.com/posts/2014/srcset-sizes/). |
@@ -60,3 +60,11 @@ import React from 'react'; | ||
} | ||
var src = this.props.photos[k].src; | ||
let src = this.props.photos[k].src, srcset, sizes; | ||
if (this.props.photos[k].srcset){ | ||
srcset = this.props.photos[k].srcset.join(); | ||
} | ||
if (this.props.photos[k].sizes){ | ||
sizes = this.props.photos[k].sizes.join(); | ||
} | ||
if (this.props.onClickPhoto){ | ||
@@ -66,3 +74,3 @@ photoPreviewNodes.push( | ||
<a href="#" className={k} onClick={(e) => this.props.onClickPhoto(k, e)}> | ||
<img src={src} style={{display:'block', border:0}} height={commonHeight} width={commonHeight * this.props.photos[k].aspectRatio} alt={this.props.photos[k].alt} /> | ||
<img src={src} srcSet={srcset} sizes={sizes} style={{display:'block', border:0}} height={commonHeight} width={commonHeight * this.props.photos[k].aspectRatio} alt={this.props.photos[k].alt} /> | ||
</a> | ||
@@ -75,3 +83,3 @@ </div> | ||
<div key={k} style={style}> | ||
<img src={src} style={{display:'block', border:0}} height={commonHeight} width={commonHeight * this.props.photos[k].aspectRatio} alt={this.props.photos[k].alt} /> | ||
<img src={src} srcSet={srcset} sizes={sizes} style={{display:'block', border:0}} height={commonHeight} width={commonHeight * this.props.photos[k].aspectRatio} alt={this.props.photos[k].alt} /> | ||
</div> | ||
@@ -111,3 +119,5 @@ ); | ||
height: React.PropTypes.number.isRequired, | ||
alt: React.PropTypes.string | ||
alt: React.PropTypes.string, | ||
srcset: React.PropTypes.array, | ||
sizes: React.PropTypes.array | ||
}) | ||
@@ -114,0 +124,0 @@ ).isRequired.apply(this,arguments); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
2988923
49265
95
436
5