Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ecodev/natural-gallery-js

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ecodev/natural-gallery-js - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

2

js/galleries/AbstractGallery.d.ts
import { Item, ItemOptions } from '../Item';
export interface ModelAttributes {
thumbnailSrc: string;
thumbnailWidth: number;
thumbnailHeight: number;
enlargedSrc?: string;

@@ -7,0 +5,0 @@ enlargedWidth?: number;

5

js/Item.d.ts

@@ -8,2 +8,3 @@ import { ModelAttributes } from './galleries/AbstractGallery';

showLabels?: 'hover' | 'never' | 'always';
cover: boolean;
}

@@ -89,6 +90,6 @@ export interface ItemTitle {

width: number;
readonly thumbnailWidth: number;
readonly thumbnailHeight: number;
readonly enlargedWidth: number;
readonly enlargedHeight: number;
readonly selected: boolean;
readonly element: HTMLElement;
}

@@ -1,1 +0,1 @@

(function(a,b){'object'==typeof exports&&'object'==typeof module?module.exports=b(require('photoswipe'),require('photoswipe/dist/photoswipe-ui-default')):'function'==typeof define&&define.amd?define('NaturalGallery',['photoswipe','photoswipe/dist/photoswipe-ui-default'],b):'object'==typeof exports?exports.NaturalGallery=b(require('photoswipe'),require('photoswipe/dist/photoswipe-ui-default')):a.NaturalGallery=b(a.photoswipe,a['photoswipe/dist/photoswipe-ui-default'])})(this,function(a,b){var c=Math.ceil,d=Math.floor;return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='',b(b.s=4)}([function(a,b,c){'use strict';var d=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var e=c(1),f=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return d(b,a),b.prototype.addRows=function(b){this.completeLastRow(),a.prototype.addRows.call(this,b)},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.completeLastRow(),this.flushBufferedItems()},b.prototype.completeLastRow=function(){var a=this;if(this.visibleCollection.length){var b=this.visibleCollection[this.visibleCollection.length-1].row,c=this.visibleCollection.filter(function(a){return a.row===b}).length,d=this.collection.slice(this.visibleCollection.length-c);this.organizeItems(d,d[0].row,d[0].row);var e=d.slice(c).filter(function(a){return a.row<=d[0].row});e.forEach(function(b){return a.addItemToDOM(b)})}},b}(e.AbstractRowGallery);b.AbstractResponsiveRowGallery=f},function(a,b,c){'use strict';var d=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var e=c(2),f=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return d(b,a),b.prototype.onScroll=function(){this.addRows(1)},b.prototype.onPageAdd=function(){this.addRows(this.getRowsPerPage())},b.prototype.addRows=function(a){var b=this,c=this.visibleCollection.length,d=this.visibleCollection.length?this.visibleCollection[c-1].row+1:0,e=d+a-1,f=this.collection.slice(c);this.organizeItems(f,d,e);var g=f.filter(function(a){return a.row<=e});g.forEach(function(a){return b.addItemToDOM(a)}),this.flushBufferedItems(),this.updateNextButtonVisibility()},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.visibleCollection.length&&this.organizeItems(this.visibleCollection)},b}(e.AbstractGallery);b.AbstractRowGallery=f},function(a,b,c){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var e=c(8),f=c(3),g=c(9),h=c(10),i=c(11),j=function(){function a(a,b,c,d){void 0===d&&(d=null),this.elementRef=a,this.userOptions=b,this.photoswipeElementRef=c,this.scrollElementRef=d,this.defaultOptions={gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null},this.photoswipeDefaultOptions={bgOpacity:0.85,showHideOpacity:!1},this.old_scroll_top=0,this._collection=[],this._visibleCollection=[],this.photoswipeCollection=[],this.scrollBufferedItems=[],this.requiredItems=0,this.init()}return a.prototype.init=function(){var a=this;this.elementRef.classList.add('natural-gallery-js'),this.flushBufferedItems=i.debounce(function(){a.scrollBufferedItems.forEach(function(b){b.loadImage(),a.dispatchEvent('item-displayed',b.model)}),a.scrollBufferedItems=[],a.requiredItems&&(a.dispatchEvent('pagination',{offset:a.collection.length,limit:a.requiredItems}),a.requiredItems=0)},500,{leading:!1,trailing:!0}),this.defaultsOptions(),this.options.lightbox&&!this.photoswipeElementRef&&console.error('Lightbox option is set to true, but no PhotoSwipe reference is given'),this.render(),this.requestItems(),this.options.rowsPerPage||this.bindScroll(null===this.scrollElementRef?document:this.scrollElementRef)},a.prototype.defaultsOptions=function(){for(var a in this.options=this.userOptions||{},this.defaultOptions)'undefined'==typeof this.options[a]&&(this.options[a]=this.defaultOptions[a])},a.prototype.requestItems=function(){var a=this.getEstimatedItemsPerRow(),b=a*(this.getRowsPerPage()+1);this.dispatchEvent('pagination',{offset:this.collection.length,limit:b})},a.prototype.getRowsPerPage=function(){if(0<this.options.rowsPerPage)return this.options.rowsPerPage;var a=this.getEstimatedRowsPerPage();return a<this.options.minRowsAtStart?this.options.minRowsAtStart:a},a.prototype.addItemToDOM=function(a,b){var c=this;void 0===b&&(b=this.bodyElementRef),this.visibleCollection.push(a),b.appendChild(a.init()),this.scrollBufferedItems.push(a),this.requiredItems++,this.dispatchEvent('item-added-to-dom',a.model),a.element.addEventListener('select',function(){c.dispatchEvent('select',c.visibleCollection.filter(function(a){return a.selected}).map(function(a){return a.model}))}),a.element.addEventListener('activate',function(a){c.dispatchEvent('activate',{model:a.detail.item.model,clickEvent:a.detail.clickEvent})}),a.element.addEventListener('zoom',function(a){c.openPhotoSwipe(a.detail)})},a.prototype.render=function(){var a=this;this.nextButton=document.createElement('div'),this.nextButton.classList.add('natural-gallery-next'),this.nextButton.appendChild(f.Utility.getIcon('natural-gallery-icon-next')),this.nextButton.style.display='none',this.nextButton.addEventListener('click',function(b){b.preventDefault(),a.onPageAdd()}),this.bodyElementRef=document.createElement('div'),this.bodyElementRef.classList.add('natural-gallery-body'),this.extendToFreeViewport();var b=document.createElement('iframe');this.elementRef.appendChild(b);var c=500,d=i.debounce(function(){return a.startResize()},c,{leading:!0,trailing:!1}),e=i.debounce(function(){return a.endResize()},c,{leading:!1,trailing:!0});b.contentWindow.addEventListener('resize',function(){e(),d()}),this.elementRef.appendChild(this.bodyElementRef),this.elementRef.appendChild(this.nextButton)},a.prototype.updateNextButtonVisibility=function(){this.nextButton.style.display=this.visibleCollection.length===this.collection.length?'none':'block'},a.prototype.addItems=function(a){var b=this;if(a.constructor===Array&&a.length){var c=this.collection.length===this.visibleCollection.length;a.forEach(function(a){var c=new e.Item(b.getItemOptions(),a);b._collection.push(c),b.photoswipeCollection.push(b.getPhotoswipeItem(c))}),c&&this.onPageAdd()}},a.prototype.getItemOptions=function(){return{lightbox:this.options.lightbox,selectable:this.options.selectable,activable:this.options.activable,gap:this.options.gap,showLabels:this.options.showLabels}},a.prototype.extendToFreeViewport=function(){return this.options.rowsPerPage?this.options.rowsPerPage:void(this.elementRef.style.minHeight=this.getGalleryVisibleHeight()+10+'px')},a.prototype.getGalleryVisibleHeight=function(){return document.documentElement.clientHeight-this.elementRef.offsetTop},a.prototype.startResize=function(){this.bodyElementRef.classList.add('resizing')},a.prototype.endResize=function(){this.bodyElementRef.classList.remove('resizing')},a.prototype.bindScroll=function(a){var b=this,c=null;c=a instanceof Document?a.documentElement:a;var d=i.debounce(function(){return b.elementRef.classList.add('scrolling')},300,{leading:!0,trailing:!1}),e=i.debounce(function(){return b.elementRef.classList.remove('scrolling')},300,{leading:!1,trailing:!0});a.addEventListener('scroll',function(){d(),e();var a=b.elementRef.offsetTop+b.elementRef.offsetHeight+b.options.infiniteScrollOffset,f=c.scrollTop-(c.clientTop||0),g=c.clientHeight,h=f-b.old_scroll_top;b.old_scroll_top=f,0<h&&f+g>=a&&b.onScroll()})},a.prototype.openPhotoSwipe=function(a){var b=this;if(this.options.lightbox&&!this.photoswipeElementRef)return void console.error('Lightbox option is set to true, but no PhotoSwipe reference is given');var c={index:this.collection.findIndex(function(b){return b===a}),loop:!1};c=Object.assign({},this.photoswipeDefaultOptions,this.options.photoSwipeOptions,c);var d=new g(this.photoswipeElementRef,h,this.photoswipeCollection,c);d.init(),d.listen('beforeChange',function(a){1===a&&d.getCurrentIndex()===b.visibleCollection.length&&b.onPageAdd()}),this.dispatchEvent('zoom',{item:a.model,photoswipe:d})},a.prototype.getPhotoswipeItem=function(a){return{src:a.model.enlargedSrc,w:a.model.enlargedWidth,h:a.model.enlargedHeight,title:a.title}},a.prototype.dispatchEvent=function(a,b){var c=new CustomEvent(a,{detail:b});this.elementRef.dispatchEvent(c)},a.prototype.selectVisibleItems=function(){return this.visibleCollection.forEach(function(a){return a.select()}),this.selectedItems},a.prototype.unselectAllItems=function(){this.visibleCollection.forEach(function(a){return a.unselect()})},a.prototype.addEventListener=function(a,b){this.elementRef.addEventListener(a,b),'pagination'===a&&this.requestItems()},a.prototype.empty=function(){this.bodyElementRef.innerHTML='',this._visibleCollection=[],this.photoswipeCollection=[],this._collection=[]},a.prototype.clear=function(){this.empty(),this.requestItems()},a.prototype.setItems=function(a){this.empty(),this.addItems(a)},Object.defineProperty(a.prototype,'collection',{get:function(){return this._collection},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'visibleCollection',{get:function(){return this._visibleCollection},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'selectedItems',{get:function(){return this.visibleCollection.filter(function(a){return a.selected}).map(function(a){return a.model})},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'width',{get:function(){return d(this.bodyElementRef.getBoundingClientRect().width)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'collectionLength',{get:function(){return this.collection.length},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'visibleCollectionLength',{get:function(){return this.visibleCollection.length},enumerable:!0,configurable:!0}),a}();b.AbstractGallery=j},function(a,b){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a.getIcon=function(a){var b=document.createElementNS('http://www.w3.org/2000/svg','svg');return b.setAttribute('viewBox','0 0 100 100'),b.innerHTML='<use xlink:href="#'+a+'"></use>',b}})(c=b.Utility||(b.Utility={}))},function(a,b,c){'use strict';function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),c(5),c(6),d(c(7)),d(c(12)),d(c(14)),d(c(15))},function(){},function(){},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(0),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={rowHeight:400,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return c((this.width+this.options.gap)/(this.options.rowHeight+this.options.gap))},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/(this.options.rowHeight+this.options.gap))+1},b.prototype.organizeItems=function(a,b,c,d){void 0===b&&(b=0),void 0===c&&(c=null),void 0===d&&(d=null),d||(d=b?b:0);for(var e=1;e<=a.length;e++){var f=a.slice(0,e),g=this.getRowWidth(this.options.rowHeight,this.options.gap,f);if(g>=this.width){this.computeSizes(f,this.width,this.options.gap,d);var h=d+1;(null===c||h<=c)&&this.organizeItems(a.slice(e),b,c,h);break}else if(e===a.length){this.computeSizes(f,null,this.options.gap,d,this.options.rowHeight);break}}},b.prototype.computeSizes=function(a,b,c,e,f){void 0===f&&(f=null);for(var g=b?this.getRowHeight(b,c,a):f,h=this.getRowWidth(g,c,a),j=b?this.apportionExcess(a,b,h):0,k=0,l=0;l<a.length;l++){var i=a[l],m=this.getImageRatio(i)*g-j;k+=m-d(m),m=d(m),(1<=k||l===a.length-1&&1===Math.round(k))&&(m++,k--),i.width=m,i.height=d(g),i.row=e,i.last=l===a.length-1,i.style()}},b.prototype.getRowWidth=function(a,b,c){return b*(c.length-1)+this.getRatios(c)*a},b.prototype.getRowHeight=function(a,b,c){return a/this.getRatios(c)+b*(c.length-1)},b.prototype.getRatios=function(a){for(var b=this,c=0,d=0;d<a.length;d++)c+=b.getImageRatio(a[d]);return c},b.prototype.getImageRatio=function(a){return+a.thumbnailWidth/+a.thumbnailHeight},b.prototype.apportionExcess=function(a,b,c){return(c-b)/a.length},b}(g.AbstractResponsiveRowGallery);b.Natural=h},function(a,b,c){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var d=c(3),e=function(){function a(a,b){this.options=a,this.model=b,this._selected=!1,this.title=this.getTitleDetails(b.title)}return a.prototype.getTitleDetails=function(a){return a.replace(/<(?!\s*br\s*\/?)[^>]+>/gi,'')},a.prototype.init=function(){var a=this,b=null;this.title&&-1<['always','hover'].indexOf(this.options.showLabels)&&(b=!0);var c=document.createElement('div'),e=document.createElement('div'),f=this.getLinkElement(),g=null,h=null;if(this.options.lightbox&&b&&f?(b=f,b.classList.add('button'),g=e,h=f):this.options.lightbox&&b&&!f?(b=document.createElement('div'),this.options.activable?(h=b,b.classList.add('button'),g=e):g=c):this.options.lightbox&&!b?g=c:!this.options.lightbox&&b&&f?(e=this.getLinkElement(),b=f,b.classList.add('button'),h=c):this.options.lightbox||!b||f?!this.options.lightbox&&!b&&f&&(e=f,h=f):(b=document.createElement('div'),this.options.activable&&(h=c,b.classList.add('button'))),g&&(g.classList.add('zoomable'),g.addEventListener('click',function(){var b=new CustomEvent('zoom',{detail:a});a._element.dispatchEvent(b)})),h&&(h.classList.add('activable'),h.addEventListener('click',function(b){var c=new CustomEvent('activate',{detail:{item:a,clickEvent:b}});a._element.dispatchEvent(c)})),e.classList.add('image'),c.classList.add('figure'),c.appendChild(e),this.model.color&&(c.style.backgroundColor=this.model.color+'11'),this._element=c,this._image=e,b&&(b.innerHTML=this.title,b.classList.add('title'),'hover'===this.options.showLabels&&b.classList.add('hover'),c.appendChild(b)),this.options.selectable){this._selectBtn=document.createElement('div');var i=d.Utility.getIcon('natural-gallery-icon-select');this._selectBtn.appendChild(i),this._selectBtn.classList.add('selectBtn'),this._selectBtn.addEventListener('click',function(b){b.stopPropagation(),a.toggleSelect();var c=new CustomEvent('select',{detail:a});a._element.dispatchEvent(c)}),this._element.appendChild(this._selectBtn)}return this.style(),c},a.prototype.style=function(){this._element&&(this._element.style.width=this.width+'px',this._element.style.height=this.height+'px',this._element.style.marginBottom=this.options.gap+'px',this._element.style.marginRight=this.last?'0':this.options.gap+'px')},a.prototype.loadImage=function(){var a=this,b=document.createElement('img');b.setAttribute('src',this.model.thumbnailSrc),this._image.style.backgroundImage='url('+this.model.thumbnailSrc+')',b.addEventListener('load',function(){a._element.classList.add('loaded')}),b.addEventListener('error',function(){a._element.classList.add('errored')})},a.prototype.toggleSelect=function(){this._selected?this.unselect():this.select()},a.prototype.select=function(){this._selected=!0,this._element.classList.add('selected')},a.prototype.unselect=function(){this._selected=!1,this._element.classList.remove('selected')},a.prototype.getLinkElement=function(){if(this.model.link){var a=document.createElement('a');return a.setAttribute('href',this.model.link),a.classList.add('link'),this.model.linkTarget&&a.setAttribute('target',this.model.linkTarget),a}return null},a.prototype.remove=function(){this._element.parentNode&&this._element.parentNode.removeChild(this._element)},Object.defineProperty(a.prototype,'last',{get:function(){return this._last},set:function(a){this._last=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'row',{get:function(){return this._row},set:function(a){this._row=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'height',{get:function(){return this._height},set:function(a){this._height=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'width',{get:function(){return this._width},set:function(a){this._width=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'thumbnailWidth',{get:function(){return this.model.thumbnailWidth},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'thumbnailHeight',{get:function(){return this.model.thumbnailHeight},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'selected',{get:function(){return this._selected},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'element',{get:function(){return this._element},enumerable:!0,configurable:!0}),a}();b.Item=e},function(b){b.exports=a},function(a){a.exports=b},function(a,b){'use strict';function c(a){const b=typeof a;return null!=a&&('object'==b||'function'==b)}Object.defineProperty(b,'__esModule',{value:!0}),b.isObject=c,b.debounce=function(a,b,d){function e(b){const c=n,d=o;return n=o=void 0,t=b,q=a.apply(d,c),q}function f(a,b){return setTimeout(a,b)}function g(a){clearTimeout(a)}function h(a){return t=a,r=f(k,b),u?e(a):q}function i(a){const c=a-s,d=a-t,e=b-c;return v?Math.min(e,p-d):e}function j(a){const c=a-s,d=a-t;return void 0==s||c>=b||0>c||v&&d>=p}function k(){const a=Date.now();return j(a)?l(a):void(r=f(k,i(a)))}function l(a){return(r=void 0,w&&n)?e(a):(n=o=void 0,q)}function m(...a){const c=Date.now(),d=j(c);if(n=a,o=this,s=c,d){if(void 0===r)return h(s);if(v)return r=f(k,b),e(s)}return void 0===r&&(r=f(k,b)),q}let n,o,p,q,r,s,t=0,u=!1,v=!1,w=!0;if('function'!=typeof a)throw new TypeError('Expected a function');return b=+b||0,c(d)&&(u=!!d.leading,v='maxWait'in d,p=v?Math.max(+d.maxWait||0,b):p,w='trailing'in d?!!d.trailing:w),m.cancel=function(){void 0!==r&&g(r),t=0,n=s=o=r=void 0},m.flush=function(){return void 0===r?q:l(Date.now())},m.pending=function(){return void 0!==r},m}},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(2),h=e(13),i=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={columnWidth:300,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null},b}return f(b,a),b.prototype.init=function(){a.prototype.init.call(this),this.addColumns()},b.prototype.onScroll=function(){this.addUntilFill()},b.prototype.onPageAdd=function(){var a=this.addUntilFill(),b=this.getEstimatedItemsPerRow(),c=this.getEstimatedRowsPerPage()*b,d=c-a;0<d&&this.addItemsToDom(d)},b.prototype.getEstimatedItemsPerRow=function(){return c((this.width-this.options.gap)/(this.options.columnWidth+this.options.gap))},b.prototype.getEstimatedRowsPerPage=function(){var a=this.getColumnWidth();return c(this.getGalleryVisibleHeight()/(a/1.75))},b.prototype.addUntilFill=function(){var a=this.elementRef.clientHeight,b=0;do b++,this.addItemsToDom(1);while(this.elementRef.clientHeight===a&&this.visibleCollection.length<this.collection.length);var c=this.getEstimatedRowsPerPage();return this.addItemsToDom(c),b+c},b.prototype.addItemsToDom=function(a){var b=this.visibleCollection.length,c=this.visibleCollection.length?b:0,d=c+a-1;this.organizeItems(this.collection.slice(b),c,d);for(var e,f=b;f<this.collection.length&&(e=this.collection[f],f<=d);f++)this.addItemToDOM(e);this.flushBufferedItems(),this.updateNextButtonVisibility()},b.prototype.addItemToDOM=function(b,c){void 0===c&&(c=null);var d=this.getShortestColumn();d.addItem(b),a.prototype.addItemToDOM.call(this,b,d.elementRef)},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.visibleCollection.length&&(this.visibleCollection.length=0,this.addColumns(),this.addUntilFill())},b.prototype.addColumns=function(){this.bodyElementRef.innerHTML='',this.columns=[];for(var a,b=this.getColumnWidth(),c=0;c<this.getEstimatedItemsPerRow();c++)a=new h.Column({width:b,gap:this.options.gap}),this.columns.push(a),this.bodyElementRef.appendChild(a.init())},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getEstimatedItemsPerRow(),f=this.getColumnWidth(),g=c?e*(c-b+1):a.length;g=g>a.length?a.length:g;for(var h,j=0;j<g;j++)h=a[j],h.last=!0,h.width=d(f),h.height=h.width*h.model.enlargedWidth/h.model.enlargedHeight,h.style()},b.prototype.getColumnWidth=function(){var a=this.getEstimatedItemsPerRow();return d((this.width-(a-1)*this.options.gap)/a)},b.prototype.getShortestColumn=function(){return this.columns.reduce(function(a,b){return a?b.height<a.height?b:a:b})},b.prototype.empty=function(){a.prototype.empty.call(this),this.addColumns()},b}(g.AbstractGallery);b.Masonry=i},function(a,b){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var c=function(){function a(a){this.options=a,this.collection=[]}return a.prototype.init=function(){return this._elementRef=document.createElement('div'),this._elementRef.classList.add('column'),this._elementRef.style.marginRight=this.options.gap+'px',this._elementRef.style.width=this.options.width+'px',this._elementRef},a.prototype.addItem=function(a){this.collection.push(a)},Object.defineProperty(a.prototype,'height',{get:function(){return this._elementRef.offsetHeight},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'length',{get:function(){return this.collection.length},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'elementRef',{get:function(){return this._elementRef},enumerable:!0,configurable:!0}),a}();b.Column=c},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(0),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={rowHeight:400,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return c((this.width+this.options.gap)/(this.options.rowHeight+this.options.gap))},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getEstimatedItemsPerRow(),f=this.getItemSideSize(),g=this.width-e*f-(e-1)*this.options.gap,h=c?e*(c-b+1):a.length;h=h>a.length?a.length:h;for(var j,k=0;k<h;k++)j=a[k],j.last=k%e==e-1,j.row=d(k/e)+b,j.width=d(f),j.height=d(f),j.last&&(j.width=d(f+g)),j.style()},b.prototype.getItemSideSize=function(){var a=this.getEstimatedItemsPerRow();return(this.width-(a-1)*this.options.gap)/a},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/this.getItemSideSize())},b}(g.AbstractResponsiveRowGallery);b.ResponsiveSquare=h},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(1),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={itemsPerRow:4,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return this.options.itemsPerRow},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getItemSideSize(),f=c?this.options.itemsPerRow*(c-b+1):a.length;f=f>a.length?a.length:f;for(var g,h=0;h<f;h++)g=a[h],g.width=d(e),g.height=d(e),g.last=h%this.options.itemsPerRow==this.options.itemsPerRow-1,g.row=d(h/this.options.itemsPerRow)+b,g.style()},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/this.getItemSideSize())},b.prototype.getItemSideSize=function(){var a=this.getEstimatedItemsPerRow();return(this.width-(a-1)*this.options.gap)/a},b}(g.AbstractRowGallery);b.Square=h}])});
(function(a,b){'object'==typeof exports&&'object'==typeof module?module.exports=b(require('photoswipe'),require('photoswipe/dist/photoswipe-ui-default')):'function'==typeof define&&define.amd?define('NaturalGallery',['photoswipe','photoswipe/dist/photoswipe-ui-default'],b):'object'==typeof exports?exports.NaturalGallery=b(require('photoswipe'),require('photoswipe/dist/photoswipe-ui-default')):a.NaturalGallery=b(a.photoswipe,a['photoswipe/dist/photoswipe-ui-default'])})(this,function(a,b){var c=Math.ceil,d=Math.floor;return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='',b(b.s=4)}([function(a,b,c){'use strict';var d=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var e=c(1),f=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return d(b,a),b.prototype.addRows=function(b){this.completeLastRow(),a.prototype.addRows.call(this,b)},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.completeLastRow(),this.flushBufferedItems()},b.prototype.completeLastRow=function(){var a=this;if(this.visibleCollection.length){var b=this.visibleCollection[this.visibleCollection.length-1].row,c=this.visibleCollection.filter(function(a){return a.row===b}).length,d=this.collection.slice(this.visibleCollection.length-c);this.organizeItems(d,d[0].row,d[0].row);var e=d.slice(c).filter(function(a){return a.row<=d[0].row});e.forEach(function(b){return a.addItemToDOM(b)})}},b}(e.AbstractRowGallery);b.AbstractResponsiveRowGallery=f},function(a,b,c){'use strict';var d=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var e=c(2),f=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return d(b,a),b.prototype.onScroll=function(){this.addRows(1)},b.prototype.onPageAdd=function(){this.addRows(this.getRowsPerPage())},b.prototype.addRows=function(a){var b=this,c=this.visibleCollection.length,d=this.visibleCollection.length?this.visibleCollection[c-1].row+1:0,e=d+a-1,f=this.collection.slice(c);this.organizeItems(f,d,e);var g=f.filter(function(a){return a.row<=e});g.forEach(function(a){return b.addItemToDOM(a)}),this.flushBufferedItems(),this.updateNextButtonVisibility()},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.visibleCollection.length&&this.organizeItems(this.visibleCollection)},b}(e.AbstractGallery);b.AbstractRowGallery=f},function(a,b,c){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var e=c(8),f=c(3),g=c(9),h=c(10),i=c(11),j=function(){function a(a,b,c,d){void 0===d&&(d=null),this.elementRef=a,this.userOptions=b,this.photoswipeElementRef=c,this.scrollElementRef=d,this.defaultOptions={gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null,cover:!0},this.photoswipeDefaultOptions={bgOpacity:0.85,showHideOpacity:!1},this.old_scroll_top=0,this._collection=[],this._visibleCollection=[],this.photoswipeCollection=[],this.scrollBufferedItems=[],this.requiredItems=0,this.init()}return a.prototype.init=function(){var a=this;this.elementRef.classList.add('natural-gallery-js'),this.flushBufferedItems=i.debounce(function(){a.scrollBufferedItems.forEach(function(b){b.loadImage(),a.dispatchEvent('item-displayed',b.model)}),a.scrollBufferedItems=[],a.requiredItems&&(a.dispatchEvent('pagination',{offset:a.collection.length,limit:a.requiredItems}),a.requiredItems=0)},500,{leading:!1,trailing:!0}),this.defaultsOptions(),this.options.lightbox&&!this.photoswipeElementRef&&console.error('Lightbox option is set to true, but no PhotoSwipe reference is given'),this.render(),this.requestItems(),this.options.rowsPerPage||this.bindScroll(null===this.scrollElementRef?document:this.scrollElementRef)},a.prototype.defaultsOptions=function(){for(var a in this.options=this.userOptions||{},this.defaultOptions)'undefined'==typeof this.options[a]&&(this.options[a]=this.defaultOptions[a])},a.prototype.requestItems=function(){var a=this.getEstimatedItemsPerRow(),b=a*(this.getRowsPerPage()+1);this.dispatchEvent('pagination',{offset:this.collection.length,limit:b})},a.prototype.getRowsPerPage=function(){if(0<this.options.rowsPerPage)return this.options.rowsPerPage;var a=this.getEstimatedRowsPerPage();return a<this.options.minRowsAtStart?this.options.minRowsAtStart:a},a.prototype.addItemToDOM=function(a,b){var c=this;void 0===b&&(b=this.bodyElementRef),this.visibleCollection.push(a),b.appendChild(a.init()),this.scrollBufferedItems.push(a),this.requiredItems++,this.dispatchEvent('item-added-to-dom',a.model),a.element.addEventListener('select',function(){c.dispatchEvent('select',c.visibleCollection.filter(function(a){return a.selected}).map(function(a){return a.model}))}),a.element.addEventListener('activate',function(a){c.dispatchEvent('activate',{model:a.detail.item.model,clickEvent:a.detail.clickEvent})}),a.element.addEventListener('zoom',function(a){c.openPhotoSwipe(a.detail)})},a.prototype.render=function(){var a=this;this.nextButton=document.createElement('div'),this.nextButton.classList.add('natural-gallery-next'),this.nextButton.appendChild(f.Utility.getIcon('natural-gallery-icon-next')),this.nextButton.style.display='none',this.nextButton.addEventListener('click',function(b){b.preventDefault(),a.onPageAdd()}),this.bodyElementRef=document.createElement('div'),this.bodyElementRef.classList.add('natural-gallery-body'),this.extendToFreeViewport();var b=document.createElement('iframe');this.elementRef.appendChild(b);var c=500,d=i.debounce(function(){return a.startResize()},c,{leading:!0,trailing:!1}),e=i.debounce(function(){return a.endResize()},c,{leading:!1,trailing:!0});b.contentWindow.addEventListener('resize',function(){e(),d()}),this.elementRef.appendChild(this.bodyElementRef),this.elementRef.appendChild(this.nextButton)},a.prototype.updateNextButtonVisibility=function(){this.nextButton.style.display=this.visibleCollection.length===this.collection.length?'none':'block'},a.prototype.addItems=function(a){var b=this;if(a.constructor===Array&&a.length){var c=this.collection.length===this.visibleCollection.length;a.forEach(function(a){var c=new e.Item(b.getItemOptions(),a);b._collection.push(c),b.photoswipeCollection.push(b.getPhotoswipeItem(c))}),c&&this.onPageAdd()}},a.prototype.getItemOptions=function(){return console.log({lightbox:this.options.lightbox,selectable:this.options.selectable,activable:this.options.activable,gap:this.options.gap,showLabels:this.options.showLabels,cover:this.options.cover}),{lightbox:this.options.lightbox,selectable:this.options.selectable,activable:this.options.activable,gap:this.options.gap,showLabels:this.options.showLabels,cover:this.options.cover}},a.prototype.extendToFreeViewport=function(){return this.options.rowsPerPage?this.options.rowsPerPage:void(this.elementRef.style.minHeight=this.getGalleryVisibleHeight()+10+'px')},a.prototype.getGalleryVisibleHeight=function(){return document.documentElement.clientHeight-this.elementRef.offsetTop},a.prototype.startResize=function(){this.bodyElementRef.classList.add('resizing')},a.prototype.endResize=function(){this.bodyElementRef.classList.remove('resizing')},a.prototype.bindScroll=function(a){var b=this,c=null;c=a instanceof Document?a.documentElement:a;var d=i.debounce(function(){return b.elementRef.classList.add('scrolling')},300,{leading:!0,trailing:!1}),e=i.debounce(function(){return b.elementRef.classList.remove('scrolling')},300,{leading:!1,trailing:!0});a.addEventListener('scroll',function(){d(),e();var a=b.elementRef.offsetTop+b.elementRef.offsetHeight+b.options.infiniteScrollOffset,f=c.scrollTop-(c.clientTop||0),g=c.clientHeight,h=f-b.old_scroll_top;b.old_scroll_top=f,0<h&&f+g>=a&&b.onScroll()})},a.prototype.openPhotoSwipe=function(a){var b=this;if(this.options.lightbox&&!this.photoswipeElementRef)return void console.error('Lightbox option is set to true, but no PhotoSwipe reference is given');var c={index:this.collection.findIndex(function(b){return b===a}),loop:!1};c=Object.assign({},this.photoswipeDefaultOptions,this.options.photoSwipeOptions,c);var d=new g(this.photoswipeElementRef,h,this.photoswipeCollection,c);d.init(),d.listen('beforeChange',function(a){1===a&&d.getCurrentIndex()===b.visibleCollection.length&&b.onPageAdd()}),this.dispatchEvent('zoom',{item:a.model,photoswipe:d})},a.prototype.getPhotoswipeItem=function(a){return{src:a.model.enlargedSrc,w:a.model.enlargedWidth,h:a.model.enlargedHeight,title:a.title}},a.prototype.dispatchEvent=function(a,b){var c=new CustomEvent(a,{detail:b});this.elementRef.dispatchEvent(c)},a.prototype.selectVisibleItems=function(){return this.visibleCollection.forEach(function(a){return a.select()}),this.selectedItems},a.prototype.unselectAllItems=function(){this.visibleCollection.forEach(function(a){return a.unselect()})},a.prototype.addEventListener=function(a,b){this.elementRef.addEventListener(a,b),'pagination'===a&&this.requestItems()},a.prototype.empty=function(){this.bodyElementRef.innerHTML='',this._visibleCollection=[],this.photoswipeCollection=[],this._collection=[]},a.prototype.clear=function(){this.empty(),this.requestItems()},a.prototype.setItems=function(a){this.empty(),this.addItems(a)},Object.defineProperty(a.prototype,'collection',{get:function(){return this._collection},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'visibleCollection',{get:function(){return this._visibleCollection},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'selectedItems',{get:function(){return this.visibleCollection.filter(function(a){return a.selected}).map(function(a){return a.model})},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'width',{get:function(){return d(this.bodyElementRef.getBoundingClientRect().width)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'collectionLength',{get:function(){return this.collection.length},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'visibleCollectionLength',{get:function(){return this.visibleCollection.length},enumerable:!0,configurable:!0}),a}();b.AbstractGallery=j},function(a,b){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var c;(function(a){a.getIcon=function(a){var b=document.createElementNS('http://www.w3.org/2000/svg','svg');return b.setAttribute('viewBox','0 0 100 100'),b.innerHTML='<use xlink:href="#'+a+'"></use>',b}})(c=b.Utility||(b.Utility={}))},function(a,b,c){'use strict';function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}Object.defineProperty(b,'__esModule',{value:!0}),c(5),c(6),d(c(7)),d(c(12)),d(c(14)),d(c(15))},function(){},function(){},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(0),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={rowHeight:400,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null,cover:!0},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return c((this.width+this.options.gap)/(this.options.rowHeight+this.options.gap))},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/(this.options.rowHeight+this.options.gap))+1},b.prototype.organizeItems=function(a,b,c,d){void 0===b&&(b=0),void 0===c&&(c=null),void 0===d&&(d=null),d||(d=b?b:0);for(var e=1;e<=a.length;e++){var f=a.slice(0,e),g=this.getRowWidth(this.options.rowHeight,this.options.gap,f);if(g>=this.width){this.computeSizes(f,this.width,this.options.gap,d);var h=d+1;(null===c||h<=c)&&this.organizeItems(a.slice(e),b,c,h);break}else if(e===a.length){this.computeSizes(f,null,this.options.gap,d,this.options.rowHeight);break}}},b.prototype.computeSizes=function(a,b,c,e,f){void 0===f&&(f=null);for(var g=b?this.getRowHeight(b,c,a):f,h=this.getRowWidth(g,c,a),j=b?this.apportionExcess(a,b,h):0,k=0,l=0;l<a.length;l++){var i=a[l],m=this.getImageRatio(i)*g-j;k+=m-d(m),m=d(m),(1<=k||l===a.length-1&&1===Math.round(k))&&(m++,k--),i.width=m,i.height=d(g),i.row=e,i.last=l===a.length-1,i.style()}},b.prototype.getRowWidth=function(a,b,c){return b*(c.length-1)+this.getRatios(c)*a},b.prototype.getRowHeight=function(a,b,c){return a/this.getRatios(c)+b*(c.length-1)},b.prototype.getRatios=function(a){for(var b=this,c=0,d=0;d<a.length;d++)c+=b.getImageRatio(a[d]);return c},b.prototype.getImageRatio=function(a){return+a.enlargedWidth/+a.enlargedHeight},b.prototype.apportionExcess=function(a,b,c){return(c-b)/a.length},b}(g.AbstractResponsiveRowGallery);b.Natural=h},function(a,b,c){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var d=c(3),e=function(){function a(a,b){this.options=a,this.model=b,this._selected=!1,this.title=this.getTitleDetails(b.title)}return a.prototype.getTitleDetails=function(a){return a.replace(/<(?!\s*br\s*\/?)[^>]+>/gi,'')},a.prototype.init=function(){var a=this,b=null;this.title&&-1<['always','hover'].indexOf(this.options.showLabels)&&(b=!0);var c=document.createElement('div'),e=document.createElement('div'),f=this.getLinkElement(),g=null,h=null;if(this.options.lightbox&&b&&f?(b=f,b.classList.add('button'),g=e,h=f):this.options.lightbox&&b&&!f?(b=document.createElement('div'),this.options.activable?(h=b,b.classList.add('button'),g=e):g=c):this.options.lightbox&&!b?g=c:!this.options.lightbox&&b&&f?(e=this.getLinkElement(),b=f,b.classList.add('button'),h=c):this.options.lightbox||!b||f?!this.options.lightbox&&!b&&f&&(e=f,h=f):(b=document.createElement('div'),this.options.activable&&(h=c,b.classList.add('button'))),g&&(g.classList.add('zoomable'),g.addEventListener('click',function(){var b=new CustomEvent('zoom',{detail:a});a._element.dispatchEvent(b)})),h&&(h.classList.add('activable'),h.addEventListener('click',function(b){var c=new CustomEvent('activate',{detail:{item:a,clickEvent:b}});a._element.dispatchEvent(c)})),this.options.cover&&e.classList.add('cover'),e.classList.add('image'),c.classList.add('figure'),c.appendChild(e),this.model.color&&(c.style.backgroundColor=this.model.color+'11'),this._element=c,this._image=e,b&&(b.innerHTML=this.title,b.classList.add('title'),'hover'===this.options.showLabels&&b.classList.add('hover'),c.appendChild(b)),this.options.selectable){this._selectBtn=document.createElement('div');var i=d.Utility.getIcon('natural-gallery-icon-select');this._selectBtn.appendChild(i),this._selectBtn.classList.add('selectBtn'),this._selectBtn.addEventListener('click',function(b){b.stopPropagation(),a.toggleSelect();var c=new CustomEvent('select',{detail:a});a._element.dispatchEvent(c)}),this._element.appendChild(this._selectBtn)}return this.style(),c},a.prototype.style=function(){this._element&&(this._element.style.width=this.width+'px',this._element.style.height=this.height+'px',this._element.style.marginBottom=this.options.gap+'px',this._element.style.marginRight=this.last?'0':this.options.gap+'px')},a.prototype.loadImage=function(){var a=this,b=document.createElement('img');b.setAttribute('src',this.model.thumbnailSrc),this._image.style.backgroundImage='url('+this.model.thumbnailSrc+')',b.addEventListener('load',function(){a._element.classList.add('loaded')}),b.addEventListener('error',function(){a._element.classList.add('errored')})},a.prototype.toggleSelect=function(){this._selected?this.unselect():this.select()},a.prototype.select=function(){this._selected=!0,this._element.classList.add('selected')},a.prototype.unselect=function(){this._selected=!1,this._element.classList.remove('selected')},a.prototype.getLinkElement=function(){if(this.model.link){var a=document.createElement('a');return a.setAttribute('href',this.model.link),a.classList.add('link'),this.model.linkTarget&&a.setAttribute('target',this.model.linkTarget),a}return null},a.prototype.remove=function(){this._element.parentNode&&this._element.parentNode.removeChild(this._element)},Object.defineProperty(a.prototype,'last',{get:function(){return this._last},set:function(a){this._last=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'row',{get:function(){return this._row},set:function(a){this._row=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'height',{get:function(){return this._height},set:function(a){this._height=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'width',{get:function(){return this._width},set:function(a){this._width=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'enlargedWidth',{get:function(){return this.model.enlargedWidth},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'enlargedHeight',{get:function(){return this.model.enlargedHeight},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'selected',{get:function(){return this._selected},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'element',{get:function(){return this._element},enumerable:!0,configurable:!0}),a}();b.Item=e},function(b){b.exports=a},function(a){a.exports=b},function(a,b){'use strict';function c(a){const b=typeof a;return null!=a&&('object'==b||'function'==b)}Object.defineProperty(b,'__esModule',{value:!0}),b.isObject=c,b.debounce=function(a,b,d){function e(b){const c=n,d=o;return n=o=void 0,t=b,q=a.apply(d,c),q}function f(a,b){return setTimeout(a,b)}function g(a){clearTimeout(a)}function h(a){return t=a,r=f(k,b),u?e(a):q}function i(a){const c=a-s,d=a-t,e=b-c;return v?Math.min(e,p-d):e}function j(a){const c=a-s,d=a-t;return void 0==s||c>=b||0>c||v&&d>=p}function k(){const a=Date.now();return j(a)?l(a):void(r=f(k,i(a)))}function l(a){return(r=void 0,w&&n)?e(a):(n=o=void 0,q)}function m(...a){const c=Date.now(),d=j(c);if(n=a,o=this,s=c,d){if(void 0===r)return h(s);if(v)return r=f(k,b),e(s)}return void 0===r&&(r=f(k,b)),q}let n,o,p,q,r,s,t=0,u=!1,v=!1,w=!0;if('function'!=typeof a)throw new TypeError('Expected a function');return b=+b||0,c(d)&&(u=!!d.leading,v='maxWait'in d,p=v?Math.max(+d.maxWait||0,b):p,w='trailing'in d?!!d.trailing:w),m.cancel=function(){void 0!==r&&g(r),t=0,n=s=o=r=void 0},m.flush=function(){return void 0===r?q:l(Date.now())},m.pending=function(){return void 0!==r},m}},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(2),h=e(13),i=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={columnWidth:300,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null,cover:!0},b}return f(b,a),b.prototype.init=function(){a.prototype.init.call(this),this.addColumns()},b.prototype.onScroll=function(){this.addUntilFill()},b.prototype.onPageAdd=function(){var a=this.addUntilFill(),b=this.getEstimatedItemsPerRow(),c=this.getEstimatedRowsPerPage()*b,d=c-a;0<d&&this.addItemsToDom(d)},b.prototype.getEstimatedItemsPerRow=function(){return c((this.width-this.options.gap)/(this.options.columnWidth+this.options.gap))},b.prototype.getEstimatedRowsPerPage=function(){var a=this.getColumnWidth();return c(this.getGalleryVisibleHeight()/(a/1.75))},b.prototype.addUntilFill=function(){var a=this.elementRef.clientHeight,b=0;do b++,this.addItemsToDom(1);while(this.elementRef.clientHeight===a&&this.visibleCollection.length<this.collection.length);var c=this.getEstimatedRowsPerPage();return this.addItemsToDom(c),b+c},b.prototype.addItemsToDom=function(a){var b=this.visibleCollection.length,c=this.visibleCollection.length?b:0,d=c+a-1;this.organizeItems(this.collection.slice(b),c,d);for(var e,f=b;f<this.collection.length&&(e=this.collection[f],f<=d);f++)this.addItemToDOM(e);this.flushBufferedItems(),this.updateNextButtonVisibility()},b.prototype.addItemToDOM=function(b,c){void 0===c&&(c=null);var d=this.getShortestColumn();d.addItem(b),a.prototype.addItemToDOM.call(this,b,d.elementRef)},b.prototype.endResize=function(){a.prototype.endResize.call(this),this.visibleCollection.length&&(this.visibleCollection.length=0,this.addColumns(),this.addUntilFill())},b.prototype.addColumns=function(){this.bodyElementRef.innerHTML='',this.columns=[];for(var a,b=this.getColumnWidth(),c=0;c<this.getEstimatedItemsPerRow();c++)a=new h.Column({width:b,gap:this.options.gap}),this.columns.push(a),this.bodyElementRef.appendChild(a.init())},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getEstimatedItemsPerRow(),f=this.getColumnWidth(),g=c?e*(c-b+1):a.length;g=g>a.length?a.length:g;for(var h,j=0;j<g;j++)h=a[j],h.last=!0,h.width=d(f),h.height=h.width*h.model.enlargedWidth/h.model.enlargedHeight,h.style()},b.prototype.getColumnWidth=function(){var a=this.getEstimatedItemsPerRow();return d((this.width-(a-1)*this.options.gap)/a)},b.prototype.getShortestColumn=function(){return this.columns.reduce(function(a,b){return a?b.height<a.height?b:a:b})},b.prototype.empty=function(){a.prototype.empty.call(this),this.addColumns()},b}(g.AbstractGallery);b.Masonry=i},function(a,b){'use strict';Object.defineProperty(b,'__esModule',{value:!0});var c=function(){function a(a){this.options=a,this.collection=[]}return a.prototype.init=function(){return this._elementRef=document.createElement('div'),this._elementRef.classList.add('column'),this._elementRef.style.marginRight=this.options.gap+'px',this._elementRef.style.width=this.options.width+'px',this._elementRef},a.prototype.addItem=function(a){this.collection.push(a)},Object.defineProperty(a.prototype,'height',{get:function(){return this._elementRef.offsetHeight},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'length',{get:function(){return this.collection.length},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,'elementRef',{get:function(){return this._elementRef},enumerable:!0,configurable:!0}),a}();b.Column=c},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(0),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={rowHeight:400,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null,cover:!0},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return c((this.width+this.options.gap)/(this.options.rowHeight+this.options.gap))},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getEstimatedItemsPerRow(),f=this.getItemSideSize(),g=this.width-e*f-(e-1)*this.options.gap,h=c?e*(c-b+1):a.length;h=h>a.length?a.length:h;for(var j,k=0;k<h;k++)j=a[k],j.last=k%e==e-1,j.row=d(k/e)+b,j.width=d(f),j.height=d(f),j.last&&(j.width=d(f+g)),j.style()},b.prototype.getItemSideSize=function(){var a=this.getEstimatedItemsPerRow();return(this.width-(a-1)*this.options.gap)/a},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/this.getItemSideSize())},b}(g.AbstractResponsiveRowGallery);b.ResponsiveSquare=h},function(a,b,e){'use strict';var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};return function(c,d){function b(){this.constructor=c}a(c,d),c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();Object.defineProperty(b,'__esModule',{value:!0});var g=e(1),h=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b.defaultOptions={itemsPerRow:4,gap:3,rowsPerPage:0,showLabels:'hover',lightbox:!1,minRowsAtStart:2,selectable:!1,activable:!1,infiniteScrollOffset:0,photoSwipeOptions:null,cover:!0},b}return f(b,a),b.prototype.getEstimatedItemsPerRow=function(){return this.options.itemsPerRow},b.prototype.organizeItems=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=null);var e=this.getItemSideSize(),f=c?this.options.itemsPerRow*(c-b+1):a.length;f=f>a.length?a.length:f;for(var g,h=0;h<f;h++)g=a[h],g.width=d(e),g.height=d(e),g.last=h%this.options.itemsPerRow==this.options.itemsPerRow-1,g.row=d(h/this.options.itemsPerRow)+b,g.style()},b.prototype.getEstimatedRowsPerPage=function(){return c(this.getGalleryVisibleHeight()/this.getItemSideSize())},b.prototype.getItemSideSize=function(){var a=this.getEstimatedItemsPerRow();return(this.width-(a-1)*this.options.gap)/a},b}(g.AbstractRowGallery);b.Square=h}])});
{
"name": "@ecodev/natural-gallery-js",
"version": "4.0.0",
"version": "4.1.0",
"description": "A lazy load, infinite scroll, natural and masonry layout gallery",

@@ -21,3 +21,3 @@ "author": "Samuel Baptista <samuel.baptista@ecodev.ch>",

"scripts": {
"dev-docs": "cd docs; jekyll serve --livereload",
"dev-docs": "cd docs; bundle exec jekyll serve --livereload",
"dev-lib": "webpack --watch --env.demo",

@@ -50,3 +50,2 @@ "build-docs": "NODE_ENV='production' webpack --env.demo",

"babili-webpack-plugin": "^0.1.2",
"bootstrap": "^3.3.6",
"browser-sync": "^2.11.1",

@@ -53,0 +52,0 @@ "browserify": "^14.5.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc