react-photo-gallery
Advanced tools
Comparing version 6.0.23 to 6.0.24
@@ -377,3 +377,5 @@ import React, { PureComponent } from 'react'; | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
@@ -380,0 +382,0 @@ }, { |
@@ -383,3 +383,5 @@ (function (global, factory) { | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
@@ -386,0 +388,0 @@ }, { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.Gallery=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function n(e,t){return t||(t=0),Number(Math.round(e+"e"+t)+"e-"+t)}function r(e){return n(e.width/e.height,2)}function o(e){var t=e.photos,o=e.columns,i=e.width,a=e.margin;if(!i)return[];var u=t.reduce(function(e,t,n){var r=Math.floor(n/o);return e[r]=e[r]?[].concat(h(e[r]),[t]):[t],e},[]),c=u.length-1;return u.map(function(e,t){var u=e.reduce(function(e,t){return e+r(t)},0),s=i-e.length*(2*a),h=t!==c||e.length>1?s/u:s/o/u;return e.map(function(e){return l({},e,{height:n(h,1),width:n(h*r(e),1)})})}).reduce(function(e,t){return[].concat(h(e),h(t))},[])}var i="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;!function(){function e(e){this.value=e}function t(t){function n(o,i){try{var a=t[o](i),u=a.value;u instanceof e?Promise.resolve(u.value).then(function(e){n("next",e)},function(e){n("throw",e)}):r(a.done?"return":"normal",a.value)}catch(e){r("throw",e)}}function r(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?n(o.key,o.arg):i=null}var o,i;this._invoke=function(e,t){return new Promise(function(r,a){var u={key:e,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}();var a=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(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)},s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},h=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},f={cursor:"pointer"},p=function(e){function t(){a(this,t);var e=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.handleClick=e.handleClick.bind(e),e}return c(t,e),u(t,[{key:"handleClick",value:function(e){var t=this.props,n=t.onClick,r=t.index;n(e,{photo:t.photo,index:r})}},{key:"render",value:function(){var e=this.props,t=e.photo,n=e.onClick,r={display:"block",float:"left",margin:e.margin};return i.createElement("img",l({style:n?l({},r,f):r},t,{onClick:n?this.handleClick:null}))}}]),t}(e.PureComponent),d=(t.shape({src:t.string.isRequired,width:t.number.isRequired,height:t.number.isRequired,alt:t.string,title:t.string,srcSet:t.array,sizes:t.array}),function(e){function t(){a(this,t);var e=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.state={containerWidth:0},e.handleResize=e.handleResize.bind(e),e.handleClick=e.handleClick.bind(e),e}return c(t,e),u(t,[{key:"componentDidMount",value:function(){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)}),window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"handleResize",value:function(e){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"handleClick",value:function(e,t){var n=t.index,r=this.props,o=r.photos;(0,r.onClick)(e,{index:n,photo:o[n],previous:o[n-1]||null,next:o[n+1]||null})}},{key:"render",value:function(){var e=this,t=this.props.ImageComponent,n=void 0===t?p:t,r=this.state.containerWidth-1,a=this.props,u=a.photos,l=a.columns,c=a.margin,s=a.onClick,h=o({width:r,columns:l,margin:c,photos:u});return i.createElement("div",{className:"react-photo-gallery--gallery"},i.createElement("div",{ref:function(t){return e._gallery=t}},h.map(function(t,r){return i.createElement(n,{key:t.key||t.src,margin:c,index:r,photo:t,onClick:s?e.handleClick:null})})),i.createElement("div",{style:{content:"",display:"table",clear:"both"}}))}}]),t}(i.Component));return d.defaultProps={columns:3,margin:2},d}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.Gallery=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function n(e,t){return t||(t=0),Number(Math.round(e+"e"+t)+"e-"+t)}function r(e){return n(e.width/e.height,2)}function o(e){var t=e.photos,o=e.columns,i=e.width,a=e.margin;if(!i)return[];var u=t.reduce(function(e,t,n){var r=Math.floor(n/o);return e[r]=e[r]?[].concat(h(e[r]),[t]):[t],e},[]),c=u.length-1;return u.map(function(e,t){var u=e.reduce(function(e,t){return e+r(t)},0),s=i-e.length*(2*a),h=t!==c||e.length>1?s/u:s/o/u;return e.map(function(e){return l({},e,{height:n(h,1),width:n(h*r(e),1)})})}).reduce(function(e,t){return[].concat(h(e),h(t))},[])}var i="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;!function(){function e(e){this.value=e}function t(t){function n(o,i){try{var a=t[o](i),u=a.value;u instanceof e?Promise.resolve(u.value).then(function(e){n("next",e)},function(e){n("throw",e)}):r(a.done?"return":"normal",a.value)}catch(e){r("throw",e)}}function r(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?n(o.key,o.arg):i=null}var o,i;this._invoke=function(e,t){return new Promise(function(r,a){var u={key:e,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}();var a=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(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)},s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},h=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},f={cursor:"pointer"},p=function(e){function t(){a(this,t);var e=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.handleClick=e.handleClick.bind(e),e}return c(t,e),u(t,[{key:"handleClick",value:function(e){var t=this.props,n=t.onClick,r=t.index;n(e,{photo:t.photo,index:r})}},{key:"render",value:function(){var e=this.props,t=e.photo,n=e.onClick,r={display:"block",float:"left",margin:e.margin};return i.createElement("img",l({style:n?l({},r,f):r},t,{onClick:n?this.handleClick:null}))}}]),t}(e.PureComponent),d=(t.shape({src:t.string.isRequired,width:t.number.isRequired,height:t.number.isRequired,alt:t.string,title:t.string,srcSet:t.array,sizes:t.array}),function(e){function t(){a(this,t);var e=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.state={containerWidth:0},e.handleResize=e.handleResize.bind(e),e.handleClick=e.handleClick.bind(e),e}return c(t,e),u(t,[{key:"componentDidMount",value:function(){this.setState({containerWidth:Math.floor(this._gallery.clientWidth)}),window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"handleResize",value:function(e){this._gallery.clientWidth!==this.state.containerWidth&&this.setState({containerWidth:Math.floor(this._gallery.clientWidth)})}},{key:"handleClick",value:function(e,t){var n=t.index,r=this.props,o=r.photos;(0,r.onClick)(e,{index:n,photo:o[n],previous:o[n-1]||null,next:o[n+1]||null})}},{key:"render",value:function(){var e=this,t=this.props.ImageComponent,n=void 0===t?p:t,r=this.state.containerWidth-1,a=this.props,u=a.photos,l=a.columns,c=a.margin,s=a.onClick,h=o({width:r,columns:l,margin:c,photos:u});return i.createElement("div",{className:"react-photo-gallery--gallery"},i.createElement("div",{ref:function(t){return e._gallery=t}},h.map(function(t,r){return i.createElement(n,{key:t.key||t.src,margin:c,index:r,photo:t,onClick:s?e.handleClick:null})})),i.createElement("div",{style:{content:"",display:"table",clear:"both"}}))}}]),t}(i.Component));return d.defaultProps={columns:3,margin:2},d}); |
@@ -61,3 +61,5 @@ 'use strict'; | ||
value: function handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
@@ -64,0 +66,0 @@ }, { |
{ | ||
"name": "react-photo-gallery", | ||
"version": "6.0.23", | ||
"version": "6.0.24", | ||
"description": "Responsive React Photo Gallery Component", | ||
@@ -5,0 +5,0 @@ "main": "lib/Gallery.js", |
@@ -24,3 +24,5 @@ import React from 'react'; | ||
handleResize(e) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
if (this._gallery.clientWidth !== this.state.containerWidth) { | ||
this.setState({ containerWidth: Math.floor(this._gallery.clientWidth) }); | ||
} | ||
} | ||
@@ -27,0 +29,0 @@ handleClick(event, { index }) { |
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
369812
1952