@pluginjs/thumbnails
Advanced tools
Comparing version 0.8.6 to 0.8.7
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
@@ -8,7 +8,5 @@ */ | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var anime = _interopDefault(require('animejs')); | ||
var Component = _interopDefault(require('@pluginjs/component')); | ||
var templateEngine = _interopDefault(require('@pluginjs/template')); | ||
var anime = require('animejs'); | ||
var Component = require('@pluginjs/component'); | ||
var templateEngine = require('@pluginjs/template'); | ||
var styled = require('@pluginjs/styled'); | ||
@@ -20,7 +18,17 @@ var classes$1 = require('@pluginjs/classes'); | ||
var decorator = require('@pluginjs/decorator'); | ||
var Swipeable = _interopDefault(require('@pluginjs/swipeable')); | ||
var ImageLoader = _interopDefault(require('@pluginjs/image-loader')); | ||
var Loader = _interopDefault(require('@pluginjs/loader')); | ||
var Breakpoints = _interopDefault(require('@pluginjs/breakpoints')); | ||
var Swipeable = require('@pluginjs/swipeable'); | ||
var ImageLoader = require('@pluginjs/image-loader'); | ||
var Loader = require('@pluginjs/loader'); | ||
var Breakpoints = require('@pluginjs/breakpoints'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var anime__default = /*#__PURE__*/_interopDefaultLegacy(anime); | ||
var Component__default = /*#__PURE__*/_interopDefaultLegacy(Component); | ||
var templateEngine__default = /*#__PURE__*/_interopDefaultLegacy(templateEngine); | ||
var Swipeable__default = /*#__PURE__*/_interopDefaultLegacy(Swipeable); | ||
var ImageLoader__default = /*#__PURE__*/_interopDefaultLegacy(ImageLoader); | ||
var Loader__default = /*#__PURE__*/_interopDefaultLegacy(Loader); | ||
var Breakpoints__default = /*#__PURE__*/_interopDefaultLegacy(Breakpoints); | ||
function _defineProperty(obj, key, value) { | ||
@@ -134,3 +142,3 @@ if (key in obj) { | ||
dependencies: dependencies | ||
}), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = _dec5(_class = _dec6(_class = class Thumbnails extends Component { | ||
}), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = _dec5(_class = _dec6(_class = class Thumbnails extends Component__default['default'] { | ||
constructor(element) { | ||
@@ -176,13 +184,13 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
initBreakpoints() { | ||
Breakpoints.init(); | ||
Breakpoints__default['default'].init(); | ||
if (Breakpoints.all().includes(this.options.breakpoint)) { | ||
if (Breakpoints__default['default'].all().includes(this.options.breakpoint)) { | ||
var breakpoint = this.options.breakpoint; | ||
var that = this; | ||
if (Breakpoints.is("".concat(breakpoint, "-"))) { | ||
if (Breakpoints__default['default'].is("".concat(breakpoint, "-"))) { | ||
classes$1.addClass(this.classes.RESPONSIVE, this.element); | ||
} | ||
Breakpoints.to(breakpoint, { | ||
Breakpoints__default['default'].to(breakpoint, { | ||
enter() { | ||
@@ -271,7 +279,7 @@ classes$1.addClass(that.classes.RESPONSIVE, that.element); | ||
if (this.options.loader) { | ||
loader = Loader.of(dom.query(".".concat(this.classes.LOADER), item), this.options.loader); | ||
loader = Loader__default['default'].of(dom.query(".".concat(this.classes.LOADER), item), this.options.loader); | ||
loader.show(); | ||
} | ||
ImageLoader.of(item.querySelector(".".concat(this.classes.IMAGE))).on('loaded', img => { | ||
ImageLoader__default['default'].of(item.querySelector(".".concat(this.classes.IMAGE))).on('loaded', img => { | ||
if (this.options.loader) { | ||
@@ -293,3 +301,3 @@ loader.hide(); | ||
this.swipeable = Swipeable.of(this.inner, { | ||
this.swipeable = Swipeable__default['default'].of(this.inner, { | ||
rebound: true, | ||
@@ -323,3 +331,3 @@ decay: true, | ||
var html = ''; | ||
html = templateEngine.render(template.call(this), { | ||
html = templateEngine__default['default'].render(template.call(this), { | ||
classes: this.classes | ||
@@ -417,3 +425,3 @@ }); | ||
opts[vertical ? 'translateY' : 'translateX'] = pos; | ||
anime(opts); | ||
anime__default['default'](opts); | ||
} else { | ||
@@ -420,0 +428,0 @@ styled.setStyle({ |
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
*/ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("animejs")),s=e(require("@pluginjs/component")),i=e(require("@pluginjs/template")),n=require("@pluginjs/styled"),a=require("@pluginjs/classes"),r=require("@pluginjs/events"),h=require("@pluginjs/dom"),l=require("@pluginjs/utils"),o=require("@pluginjs/decorator"),c=e(require("@pluginjs/swipeable")),d=e(require("@pluginjs/image-loader")),p=e(require("@pluginjs/loader")),u=e(require("@pluginjs/breakpoints"));function g(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function m(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function v(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?m(Object(s),!0).forEach((function(t){g(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):m(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var b,E={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"},f={templates:{inner:()=>'<div class="{classes.INNER}"></div>',thumb:()=>'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},D=o.themeable()(b=o.styleable({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(b=o.eventable(E)(b=o.stateable()(b=o.optionable(f,!0)(b=o.register("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(b=class extends s{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.setupOptions(t),this.distance=0,this.pos=0,this.current=null,this.dif=null,this.setupClasses(),this.setupStates(),this.initialize()}initialize(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(E.READY))}initBreakpoints(){if(u.init(),u.all().includes(this.options.breakpoint)){var e=this.options.breakpoint,t=this;u.is("".concat(e,"-"))&&a.addClass(this.classes.RESPONSIVE,this.element),u.to(e,{enter(){a.addClass(t.classes.RESPONSIVE,t.element)},leave(){a.removeClass(t.classes.RESPONSIVE,t.element)}})}}parseHtml(){var e=[],t=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return t.length>0&&t.forEach(t=>{var i=h.closest(".".concat(this.classes.THUMB),t),n={src:t.getAttribute("src")||window.getComputedStyle(t)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};i&&(n.type=a.hasClass(this.classes.VIDEO,i)?"video":"image");var r=Object.entries(t.dataset).reduce((e,t)=>{var[s,i]=t;try{var n=JSON.parse('{"data": '.concat(i.replace(/'/g,'"'),"}")).data;return v(v({},e),{},{[s]:n})}catch(t){return v(v({},e),{},{[s]:i})}},{});n=l.deepMerge(n,r),e.push(n)}),e}generate(){a.addClass(this.classes.THUMBS,this.element),this.options.theme&&a.addClass(this.getThemeClass(),this.element),this.options.vertical&&a.addClass(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach((e,t)=>{var s=this.getElement("thumb");"video"===e.type&&a.addClass(this.classes.VIDEO,s),h.setData("index",t,s),s.querySelector(".".concat(this.classes.IMAGE)).setAttribute("src",e.src),h.append(s,this.inner)}),this.element.innerHTML="",h.append(this.inner,this.element)}initImageLoader(){this.items.forEach(e=>{var t="";this.options.loader&&(t=p.of(h.query(".".concat(this.classes.LOADER),e),this.options.loader)).show(),d.of(e.querySelector(".".concat(this.classes.IMAGE))).on("loaded",e=>{this.options.loader&&t.hide(),a.addClass(this.classes.LOADED,h.closest(".".concat(this.classes.THUMB),e))})})}initSwipeable(){var e=this,t=()=>{this.pos=this.swipeable.position[this.options.vertical?"y":"x"]};this.swipeable=c.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart(){e.enter("dragged")},onDecayend(){t()},onReboundend(){t()},onEnd(){t()}})}getElement(e){var t,s=this.options.templates[e];return t=i.render(s.call(this),{classes:this.classes}),h.parseHTML(t)}setDistance(e){this.wrapDistance=e?n.outerHeight(this.element):n.outerWidth(this.element),this.innerDistance=e?this.inner.scrollHeight:this.inner.scrollWidth}setItemDistance(e){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[e?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=e?n.outerHeight(this.items[0]):n.outerWidth(this.items[0]))}bind(){r.bindEvent(this.eventName("click"),e=>{if(this.is("dragged"))return this.leave("dragged"),!1;if(this.is("disable")||this.swipeable.is("paning"))return!1;var t=h.closest(".".concat(this.classes.THUMB),e.target);if(!t)return!1;var s=Number(h.getData("index",t));return this.go(s)},this.element)}unbind(){r.removeEvent(this.eventName(),this.element)}getItemPos(e){return(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.distance/2:this.distance)-this.distance*(e+1)-this.gutter*e}setPos(e){var s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.options.mode,r=0;if("full"===a){if(this.innerDistance>this.wrapDistance){var h=this.wrapDistance-this.innerDistance;if(null===this.current){var l=this.getItemPos(e);r=h<l?l:h}else if(this.current===this.length-1&&0===e)r=0;else if(0===this.current&&e===this.length-1)r=h;else{var o=this.pos;if(e>this.current){var c=o-this.distance-this.gutter;r=h<c?c:h}else if(e<this.current){var d=o+this.distance+this.gutter;r=d>0?0:d}}}}else"center"===a&&(r=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(e,!0));if(i){var p={targets:this.inner,easing:"linear",duration:300};p[s?"translateY":"translateX"]=r,t(p)}else n.setStyle({transform:"".concat(s?"translateY":"translateX","(").concat(r,"px)")},this.inner);this.pos=r}resetPos(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==t){this.setItemDistance(this.options.vertical);var s=this.pos,i=this.wrapDistance-this.innerDistance,a=0;i>0||(null===this.dif&&(this.dif=i),"center"===this.options.mode?a=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((a=this.current===this.length-1?s+(i-this.dif):s)>0&&(a=0),a<i&&(a=i)),this.dif=i,n.setStyle({transform:"".concat(e?"translateY":"translateX","(").concat(a,"px)")},this.inner),this.pos=a)}}go(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||e<0||e>this.length||e===this.current||(this.setPos(e,this.options.vertical,s),a.removeClass(this.classes.ACTIVE,this.items[this.current]),a.addClass(this.classes.ACTIVE,this.items[e]),this.current=e,t&&this.trigger(E.CHANGE))}next(){this.is("disable")||(this.go(this.current+1),this.trigger(E.NEXT))}prev(){this.is("disable")||(this.go(this.current-1),this.trigger(E.PREV))}resize(){this.resetPos(this.options.vertical)}enable(){this.is("disable")&&(a.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(E.ENABLE)}disable(){this.is("disable")||(a.addClass(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(E.DISABLE)}destroy(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&a.removeClass(this.classes.VERTICAL,this.element),this.options.theme&&a.removeClass(this.getThemeClass(),this.element),this.is("disabled")&&(a.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(E.DESTROY),super.destroy()}})||b)||b)||b)||b)||b)||b;module.exports=D; | ||
"use strict";var e=require("animejs"),t=require("@pluginjs/component"),s=require("@pluginjs/template"),i=require("@pluginjs/styled"),a=require("@pluginjs/classes"),n=require("@pluginjs/events"),r=require("@pluginjs/dom"),l=require("@pluginjs/utils"),h=require("@pluginjs/decorator"),o=require("@pluginjs/swipeable"),c=require("@pluginjs/image-loader"),d=require("@pluginjs/loader"),p=require("@pluginjs/breakpoints");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=u(e),m=u(t),v=u(s),b=u(o),E=u(c),f=u(d),D=u(p);function y(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function I(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function O(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?I(Object(s),!0).forEach((function(t){y(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):I(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var A,S={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"},C={templates:{inner:()=>'<div class="{classes.INNER}"></div>',thumb:()=>'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},j=h.themeable()(A=h.styleable({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(A=h.eventable(S)(A=h.stateable()(A=h.optionable(C,!0)(A=h.register("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(A=class extends m.default{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.setupOptions(t),this.distance=0,this.pos=0,this.current=null,this.dif=null,this.setupClasses(),this.setupStates(),this.initialize()}initialize(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(S.READY))}initBreakpoints(){if(D.default.init(),D.default.all().includes(this.options.breakpoint)){var e=this.options.breakpoint,t=this;D.default.is("".concat(e,"-"))&&a.addClass(this.classes.RESPONSIVE,this.element),D.default.to(e,{enter(){a.addClass(t.classes.RESPONSIVE,t.element)},leave(){a.removeClass(t.classes.RESPONSIVE,t.element)}})}}parseHtml(){var e=[],t=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return t.length>0&&t.forEach((t=>{var i=r.closest(".".concat(this.classes.THUMB),t),n={src:t.getAttribute("src")||window.getComputedStyle(t)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};i&&(n.type=a.hasClass(this.classes.VIDEO,i)?"video":"image");var h=Object.entries(t.dataset).reduce(((e,t)=>{var[s,i]=t;try{var a=JSON.parse('{"data": '.concat(i.replace(/'/g,'"'),"}")).data;return O(O({},e),{},{[s]:a})}catch(t){return O(O({},e),{},{[s]:i})}}),{});n=l.deepMerge(n,h),e.push(n)})),e}generate(){a.addClass(this.classes.THUMBS,this.element),this.options.theme&&a.addClass(this.getThemeClass(),this.element),this.options.vertical&&a.addClass(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach(((e,t)=>{var s=this.getElement("thumb");"video"===e.type&&a.addClass(this.classes.VIDEO,s),r.setData("index",t,s),s.querySelector(".".concat(this.classes.IMAGE)).setAttribute("src",e.src),r.append(s,this.inner)})),this.element.innerHTML="",r.append(this.inner,this.element)}initImageLoader(){this.items.forEach((e=>{var t="";this.options.loader&&(t=f.default.of(r.query(".".concat(this.classes.LOADER),e),this.options.loader)).show(),E.default.of(e.querySelector(".".concat(this.classes.IMAGE))).on("loaded",(e=>{this.options.loader&&t.hide(),a.addClass(this.classes.LOADED,r.closest(".".concat(this.classes.THUMB),e))}))}))}initSwipeable(){var e=this,t=()=>{this.pos=this.swipeable.position[this.options.vertical?"y":"x"]};this.swipeable=b.default.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart(){e.enter("dragged")},onDecayend(){t()},onReboundend(){t()},onEnd(){t()}})}getElement(e){var t,s=this.options.templates[e];return t=v.default.render(s.call(this),{classes:this.classes}),r.parseHTML(t)}setDistance(e){this.wrapDistance=e?i.outerHeight(this.element):i.outerWidth(this.element),this.innerDistance=e?this.inner.scrollHeight:this.inner.scrollWidth}setItemDistance(e){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[e?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=e?i.outerHeight(this.items[0]):i.outerWidth(this.items[0]))}bind(){n.bindEvent(this.eventName("click"),(e=>{if(this.is("dragged"))return this.leave("dragged"),!1;if(this.is("disable")||this.swipeable.is("paning"))return!1;var t=r.closest(".".concat(this.classes.THUMB),e.target);if(!t)return!1;var s=Number(r.getData("index",t));return this.go(s)}),this.element)}unbind(){n.removeEvent(this.eventName(),this.element)}getItemPos(e){return(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.distance/2:this.distance)-this.distance*(e+1)-this.gutter*e}setPos(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.options.mode,n=0;if("full"===a){if(this.innerDistance>this.wrapDistance){var r=this.wrapDistance-this.innerDistance;if(null===this.current){var l=this.getItemPos(e);n=r<l?l:r}else if(this.current===this.length-1&&0===e)n=0;else if(0===this.current&&e===this.length-1)n=r;else{var h=this.pos;if(e>this.current){var o=h-this.distance-this.gutter;n=r<o?o:r}else if(e<this.current){var c=h+this.distance+this.gutter;n=c>0?0:c}}}}else"center"===a&&(n=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(e,!0));if(s){var d={targets:this.inner,easing:"linear",duration:300};d[t?"translateY":"translateX"]=n,g.default(d)}else i.setStyle({transform:"".concat(t?"translateY":"translateX","(").concat(n,"px)")},this.inner);this.pos=n}resetPos(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==t){this.setItemDistance(this.options.vertical);var s=this.pos,a=this.wrapDistance-this.innerDistance,n=0;a>0||(null===this.dif&&(this.dif=a),"center"===this.options.mode?n=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((n=this.current===this.length-1?s+(a-this.dif):s)>0&&(n=0),n<a&&(n=a)),this.dif=a,i.setStyle({transform:"".concat(e?"translateY":"translateX","(").concat(n,"px)")},this.inner),this.pos=n)}}go(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||e<0||e>this.length||e===this.current||(this.setPos(e,this.options.vertical,s),a.removeClass(this.classes.ACTIVE,this.items[this.current]),a.addClass(this.classes.ACTIVE,this.items[e]),this.current=e,t&&this.trigger(S.CHANGE))}next(){this.is("disable")||(this.go(this.current+1),this.trigger(S.NEXT))}prev(){this.is("disable")||(this.go(this.current-1),this.trigger(S.PREV))}resize(){this.resetPos(this.options.vertical)}enable(){this.is("disable")&&(a.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(S.ENABLE)}disable(){this.is("disable")||(a.addClass(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(S.DISABLE)}destroy(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&a.removeClass(this.classes.VERTICAL,this.element),this.options.theme&&a.removeClass(this.getThemeClass(),this.element),this.is("disabled")&&(a.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(S.DESTROY),super.destroy()}})||A)||A)||A)||A)||A)||A;module.exports=j; |
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
@@ -5,0 +5,0 @@ */ |
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
*/ | ||
import t from"animejs";import e from"@pluginjs/component";import s from"@pluginjs/template";import{outerHeight as i,outerWidth as n,setStyle as r}from"@pluginjs/styled";import{addClass as a,removeClass as h,hasClass as o}from"@pluginjs/classes";import{bindEvent as l,removeEvent as c}from"@pluginjs/events";import{closest as p,setData as d,append as m,query as g,parseHTML as u,getData as v}from"@pluginjs/dom";import{deepMerge as f}from"@pluginjs/utils";import{themeable as E,styleable as b,eventable as D,stateable as y,optionable as I,register as O}from"@pluginjs/decorator";import A from"@pluginjs/swipeable";import S from"@pluginjs/image-loader";import j from"@pluginjs/loader";import w from"@pluginjs/breakpoints";function P(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function T(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,i)}return s}function L(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?T(Object(s),!0).forEach((function(e){P(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):T(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}var N,R={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"},B={templates:{inner:()=>'<div class="{classes.INNER}"></div>',thumb:()=>'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},M=E()(N=b({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(N=D(R)(N=y()(N=I(B,!0)(N=O("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(N=class extends e{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),this.setupOptions(e),this.distance=0,this.pos=0,this.current=null,this.dif=null,this.setupClasses(),this.setupStates(),this.initialize()}initialize(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(R.READY))}initBreakpoints(){if(w.init(),w.all().includes(this.options.breakpoint)){var t=this.options.breakpoint,e=this;w.is("".concat(t,"-"))&&a(this.classes.RESPONSIVE,this.element),w.to(t,{enter(){a(e.classes.RESPONSIVE,e.element)},leave(){h(e.classes.RESPONSIVE,e.element)}})}}parseHtml(){var t=[],e=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return e.length>0&&e.forEach(e=>{var i=p(".".concat(this.classes.THUMB),e),n={src:e.getAttribute("src")||window.getComputedStyle(e)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};i&&(n.type=o(this.classes.VIDEO,i)?"video":"image");var r=Object.entries(e.dataset).reduce((t,e)=>{var[s,i]=e;try{var n=JSON.parse('{"data": '.concat(i.replace(/'/g,'"'),"}")).data;return L(L({},t),{},{[s]:n})}catch(e){return L(L({},t),{},{[s]:i})}},{});n=f(n,r),t.push(n)}),t}generate(){a(this.classes.THUMBS,this.element),this.options.theme&&a(this.getThemeClass(),this.element),this.options.vertical&&a(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach((t,e)=>{var s=this.getElement("thumb");"video"===t.type&&a(this.classes.VIDEO,s),d("index",e,s),s.querySelector(".".concat(this.classes.IMAGE)).setAttribute("src",t.src),m(s,this.inner)}),this.element.innerHTML="",m(this.inner,this.element)}initImageLoader(){this.items.forEach(t=>{var e="";this.options.loader&&(e=j.of(g(".".concat(this.classes.LOADER),t),this.options.loader)).show(),S.of(t.querySelector(".".concat(this.classes.IMAGE))).on("loaded",t=>{this.options.loader&&e.hide(),a(this.classes.LOADED,p(".".concat(this.classes.THUMB),t))})})}initSwipeable(){var t=this,e=()=>{this.pos=this.swipeable.position[this.options.vertical?"y":"x"]};this.swipeable=A.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart(){t.enter("dragged")},onDecayend(){e()},onReboundend(){e()},onEnd(){e()}})}getElement(t){var e,i=this.options.templates[t];return e=s.render(i.call(this),{classes:this.classes}),u(e)}setDistance(t){this.wrapDistance=t?i(this.element):n(this.element),this.innerDistance=t?this.inner.scrollHeight:this.inner.scrollWidth}setItemDistance(t){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[t?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=t?i(this.items[0]):n(this.items[0]))}bind(){l(this.eventName("click"),t=>{if(this.is("dragged"))return this.leave("dragged"),!1;if(this.is("disable")||this.swipeable.is("paning"))return!1;var e=p(".".concat(this.classes.THUMB),t.target);if(!e)return!1;var s=Number(v("index",e));return this.go(s)},this.element)}unbind(){c(this.eventName(),this.element)}getItemPos(t){return(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.distance/2:this.distance)-this.distance*(t+1)-this.gutter*t}setPos(e){var s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.options.mode,a=0;if("full"===n){if(this.innerDistance>this.wrapDistance){var h=this.wrapDistance-this.innerDistance;if(null===this.current){var o=this.getItemPos(e);a=h<o?o:h}else if(this.current===this.length-1&&0===e)a=0;else if(0===this.current&&e===this.length-1)a=h;else{var l=this.pos;if(e>this.current){var c=l-this.distance-this.gutter;a=h<c?c:h}else if(e<this.current){var p=l+this.distance+this.gutter;a=p>0?0:p}}}}else"center"===n&&(a=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(e,!0));if(i){var d={targets:this.inner,easing:"linear",duration:300};d[s?"translateY":"translateX"]=a,t(d)}else r({transform:"".concat(s?"translateY":"translateX","(").concat(a,"px)")},this.inner);this.pos=a}resetPos(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==e){this.setItemDistance(this.options.vertical);var s=this.pos,i=this.wrapDistance-this.innerDistance,n=0;i>0||(null===this.dif&&(this.dif=i),"center"===this.options.mode?n=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((n=this.current===this.length-1?s+(i-this.dif):s)>0&&(n=0),n<i&&(n=i)),this.dif=i,r({transform:"".concat(t?"translateY":"translateX","(").concat(n,"px)")},this.inner),this.pos=n)}}go(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||t<0||t>this.length||t===this.current||(this.setPos(t,this.options.vertical,s),h(this.classes.ACTIVE,this.items[this.current]),a(this.classes.ACTIVE,this.items[t]),this.current=t,e&&this.trigger(R.CHANGE))}next(){this.is("disable")||(this.go(this.current+1),this.trigger(R.NEXT))}prev(){this.is("disable")||(this.go(this.current-1),this.trigger(R.PREV))}resize(){this.resetPos(this.options.vertical)}enable(){this.is("disable")&&(h(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(R.ENABLE)}disable(){this.is("disable")||(a(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(R.DISABLE)}destroy(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&h(this.classes.VERTICAL,this.element),this.options.theme&&h(this.getThemeClass(),this.element),this.is("disabled")&&(h(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(R.DESTROY),super.destroy()}})||N)||N)||N)||N)||N)||N;export default M; | ||
import t from"animejs";import e from"@pluginjs/component";import s from"@pluginjs/template";import{outerHeight as i,outerWidth as n,setStyle as r}from"@pluginjs/styled";import{addClass as a,removeClass as h,hasClass as o}from"@pluginjs/classes";import{bindEvent as l,removeEvent as c}from"@pluginjs/events";import{closest as p,setData as d,append as m,query as g,parseHTML as u,getData as v}from"@pluginjs/dom";import{deepMerge as f}from"@pluginjs/utils";import{themeable as E,styleable as b,eventable as D,stateable as y,optionable as I,register as O}from"@pluginjs/decorator";import A from"@pluginjs/swipeable";import S from"@pluginjs/image-loader";import j from"@pluginjs/loader";import w from"@pluginjs/breakpoints";function P(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function T(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,i)}return s}function L(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?T(Object(s),!0).forEach((function(e){P(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):T(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}var N,R={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"},B={templates:{inner:()=>'<div class="{classes.INNER}"></div>',thumb:()=>'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},M=E()(N=b({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(N=D(R)(N=y()(N=I(B,!0)(N=O("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(N=class extends e{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),this.setupOptions(e),this.distance=0,this.pos=0,this.current=null,this.dif=null,this.setupClasses(),this.setupStates(),this.initialize()}initialize(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(R.READY))}initBreakpoints(){if(w.init(),w.all().includes(this.options.breakpoint)){var t=this.options.breakpoint,e=this;w.is("".concat(t,"-"))&&a(this.classes.RESPONSIVE,this.element),w.to(t,{enter(){a(e.classes.RESPONSIVE,e.element)},leave(){h(e.classes.RESPONSIVE,e.element)}})}}parseHtml(){var t=[],e=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return e.length>0&&e.forEach((e=>{var i=p(".".concat(this.classes.THUMB),e),n={src:e.getAttribute("src")||window.getComputedStyle(e)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};i&&(n.type=o(this.classes.VIDEO,i)?"video":"image");var r=Object.entries(e.dataset).reduce(((t,e)=>{var[s,i]=e;try{var n=JSON.parse('{"data": '.concat(i.replace(/'/g,'"'),"}")).data;return L(L({},t),{},{[s]:n})}catch(e){return L(L({},t),{},{[s]:i})}}),{});n=f(n,r),t.push(n)})),t}generate(){a(this.classes.THUMBS,this.element),this.options.theme&&a(this.getThemeClass(),this.element),this.options.vertical&&a(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach(((t,e)=>{var s=this.getElement("thumb");"video"===t.type&&a(this.classes.VIDEO,s),d("index",e,s),s.querySelector(".".concat(this.classes.IMAGE)).setAttribute("src",t.src),m(s,this.inner)})),this.element.innerHTML="",m(this.inner,this.element)}initImageLoader(){this.items.forEach((t=>{var e="";this.options.loader&&(e=j.of(g(".".concat(this.classes.LOADER),t),this.options.loader)).show(),S.of(t.querySelector(".".concat(this.classes.IMAGE))).on("loaded",(t=>{this.options.loader&&e.hide(),a(this.classes.LOADED,p(".".concat(this.classes.THUMB),t))}))}))}initSwipeable(){var t=this,e=()=>{this.pos=this.swipeable.position[this.options.vertical?"y":"x"]};this.swipeable=A.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart(){t.enter("dragged")},onDecayend(){e()},onReboundend(){e()},onEnd(){e()}})}getElement(t){var e,i=this.options.templates[t];return e=s.render(i.call(this),{classes:this.classes}),u(e)}setDistance(t){this.wrapDistance=t?i(this.element):n(this.element),this.innerDistance=t?this.inner.scrollHeight:this.inner.scrollWidth}setItemDistance(t){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[t?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=t?i(this.items[0]):n(this.items[0]))}bind(){l(this.eventName("click"),(t=>{if(this.is("dragged"))return this.leave("dragged"),!1;if(this.is("disable")||this.swipeable.is("paning"))return!1;var e=p(".".concat(this.classes.THUMB),t.target);if(!e)return!1;var s=Number(v("index",e));return this.go(s)}),this.element)}unbind(){c(this.eventName(),this.element)}getItemPos(t){return(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.distance/2:this.distance)-this.distance*(t+1)-this.gutter*t}setPos(e){var s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.options.mode,a=0;if("full"===n){if(this.innerDistance>this.wrapDistance){var h=this.wrapDistance-this.innerDistance;if(null===this.current){var o=this.getItemPos(e);a=h<o?o:h}else if(this.current===this.length-1&&0===e)a=0;else if(0===this.current&&e===this.length-1)a=h;else{var l=this.pos;if(e>this.current){var c=l-this.distance-this.gutter;a=h<c?c:h}else if(e<this.current){var p=l+this.distance+this.gutter;a=p>0?0:p}}}}else"center"===n&&(a=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(e,!0));if(i){var d={targets:this.inner,easing:"linear",duration:300};d[s?"translateY":"translateX"]=a,t(d)}else r({transform:"".concat(s?"translateY":"translateX","(").concat(a,"px)")},this.inner);this.pos=a}resetPos(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==e){this.setItemDistance(this.options.vertical);var s=this.pos,i=this.wrapDistance-this.innerDistance,n=0;i>0||(null===this.dif&&(this.dif=i),"center"===this.options.mode?n=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((n=this.current===this.length-1?s+(i-this.dif):s)>0&&(n=0),n<i&&(n=i)),this.dif=i,r({transform:"".concat(t?"translateY":"translateX","(").concat(n,"px)")},this.inner),this.pos=n)}}go(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||t<0||t>this.length||t===this.current||(this.setPos(t,this.options.vertical,s),h(this.classes.ACTIVE,this.items[this.current]),a(this.classes.ACTIVE,this.items[t]),this.current=t,e&&this.trigger(R.CHANGE))}next(){this.is("disable")||(this.go(this.current+1),this.trigger(R.NEXT))}prev(){this.is("disable")||(this.go(this.current-1),this.trigger(R.PREV))}resize(){this.resetPos(this.options.vertical)}enable(){this.is("disable")&&(h(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(R.ENABLE)}disable(){this.is("disable")||(a(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(R.DISABLE)}destroy(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&h(this.classes.VERTICAL,this.element),this.options.theme&&h(this.getThemeClass(),this.element),this.is("disabled")&&(h(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(R.DESTROY),super.destroy()}})||N)||N)||N)||N)||N)||N;export default M; |
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
@@ -9,13 +9,15 @@ */ | ||
typeof define === 'function' && define.amd ? define(['animejs', '@pluginjs/component', '@pluginjs/template', '@pluginjs/styled', '@pluginjs/classes', '@pluginjs/events', '@pluginjs/dom', '@pluginjs/utils', '@pluginjs/decorator', '@pluginjs/swipeable', '@pluginjs/image-loader', '@pluginjs/loader', '@pluginjs/breakpoints'], factory) : | ||
(global = global || self, global['@pluginjs/thumbnails'] = factory(global.anime, global['@pluginjs/component'], global['@pluginjs/template'], global['@pluginjs/styled'], global['@pluginjs/classes'], global['@pluginjs/events'], global['@pluginjs/dom'], global['@pluginjs/utils'], global['@pluginjs/decorator'], global['@pluginjs/swipeable'], global['@pluginjs/image-loader'], global['@pluginjs/loader'], global['@pluginjs/breakpoints'])); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['@pluginjs/thumbnails'] = factory(global.anime, global['@pluginjs/component'], global['@pluginjs/template'], global['@pluginjs/styled'], global['@pluginjs/classes'], global['@pluginjs/events'], global['@pluginjs/dom'], global['@pluginjs/utils'], global['@pluginjs/decorator'], global['@pluginjs/swipeable'], global['@pluginjs/image-loader'], global['@pluginjs/loader'], global['@pluginjs/breakpoints'])); | ||
}(this, (function (anime, Component, templateEngine, styled, classes$1, events$1, dom, utils, decorator, Swipeable, ImageLoader, Loader, Breakpoints) { 'use strict'; | ||
anime = anime && Object.prototype.hasOwnProperty.call(anime, 'default') ? anime['default'] : anime; | ||
Component = Component && Object.prototype.hasOwnProperty.call(Component, 'default') ? Component['default'] : Component; | ||
templateEngine = templateEngine && Object.prototype.hasOwnProperty.call(templateEngine, 'default') ? templateEngine['default'] : templateEngine; | ||
Swipeable = Swipeable && Object.prototype.hasOwnProperty.call(Swipeable, 'default') ? Swipeable['default'] : Swipeable; | ||
ImageLoader = ImageLoader && Object.prototype.hasOwnProperty.call(ImageLoader, 'default') ? ImageLoader['default'] : ImageLoader; | ||
Loader = Loader && Object.prototype.hasOwnProperty.call(Loader, 'default') ? Loader['default'] : Loader; | ||
Breakpoints = Breakpoints && Object.prototype.hasOwnProperty.call(Breakpoints, 'default') ? Breakpoints['default'] : Breakpoints; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var anime__default = /*#__PURE__*/_interopDefaultLegacy(anime); | ||
var Component__default = /*#__PURE__*/_interopDefaultLegacy(Component); | ||
var templateEngine__default = /*#__PURE__*/_interopDefaultLegacy(templateEngine); | ||
var Swipeable__default = /*#__PURE__*/_interopDefaultLegacy(Swipeable); | ||
var ImageLoader__default = /*#__PURE__*/_interopDefaultLegacy(ImageLoader); | ||
var Loader__default = /*#__PURE__*/_interopDefaultLegacy(Loader); | ||
var Breakpoints__default = /*#__PURE__*/_interopDefaultLegacy(Breakpoints); | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -129,3 +131,3 @@ if (!(instance instanceof Constructor)) { | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
@@ -375,13 +377,13 @@ } catch (e) { | ||
value: function initBreakpoints() { | ||
Breakpoints.init(); | ||
Breakpoints__default['default'].init(); | ||
if (Breakpoints.all().includes(this.options.breakpoint)) { | ||
if (Breakpoints__default['default'].all().includes(this.options.breakpoint)) { | ||
var breakpoint = this.options.breakpoint; | ||
var that = this; | ||
if (Breakpoints.is("".concat(breakpoint, "-"))) { | ||
if (Breakpoints__default['default'].is("".concat(breakpoint, "-"))) { | ||
classes$1.addClass(this.classes.RESPONSIVE, this.element); | ||
} | ||
Breakpoints.to(breakpoint, { | ||
Breakpoints__default['default'].to(breakpoint, { | ||
enter: function enter() { | ||
@@ -475,7 +477,7 @@ classes$1.addClass(that.classes.RESPONSIVE, that.element); | ||
if (_this4.options.loader) { | ||
loader = Loader.of(dom.query(".".concat(_this4.classes.LOADER), item), _this4.options.loader); | ||
loader = Loader__default['default'].of(dom.query(".".concat(_this4.classes.LOADER), item), _this4.options.loader); | ||
loader.show(); | ||
} | ||
ImageLoader.of(item.querySelector(".".concat(_this4.classes.IMAGE))).on('loaded', function (img) { | ||
ImageLoader__default['default'].of(item.querySelector(".".concat(_this4.classes.IMAGE))).on('loaded', function (img) { | ||
if (_this4.options.loader) { | ||
@@ -500,3 +502,3 @@ loader.hide(); | ||
this.swipeable = Swipeable.of(this.inner, { | ||
this.swipeable = Swipeable__default['default'].of(this.inner, { | ||
rebound: true, | ||
@@ -526,3 +528,3 @@ decay: true, | ||
var html = ''; | ||
html = templateEngine.render(template.call(this), { | ||
html = templateEngine__default['default'].render(template.call(this), { | ||
classes: this.classes | ||
@@ -629,3 +631,3 @@ }); | ||
opts[vertical ? 'translateY' : 'translateX'] = pos; | ||
anime(opts); | ||
anime__default['default'](opts); | ||
} else { | ||
@@ -782,3 +784,3 @@ styled.setStyle({ | ||
return Thumbnails; | ||
}(Component)) || _class) || _class) || _class) || _class) || _class) || _class); | ||
}(Component__default['default'])) || _class) || _class) || _class) || _class) || _class) || _class); | ||
@@ -785,0 +787,0 @@ return Thumbnails; |
/*! | ||
* @pluginjs/thumbnails v0.8.6 (https://pluginjs.com) | ||
* Copyright 2020 Creation Studio Limited | ||
* @pluginjs/thumbnails v0.8.7 (https://pluginjs.com) | ||
* Copyright 2021 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("animejs"),require("@pluginjs/component"),require("@pluginjs/template"),require("@pluginjs/styled"),require("@pluginjs/classes"),require("@pluginjs/events"),require("@pluginjs/dom"),require("@pluginjs/utils"),require("@pluginjs/decorator"),require("@pluginjs/swipeable"),require("@pluginjs/image-loader"),require("@pluginjs/loader"),require("@pluginjs/breakpoints")):"function"==typeof define&&define.amd?define(["animejs","@pluginjs/component","@pluginjs/template","@pluginjs/styled","@pluginjs/classes","@pluginjs/events","@pluginjs/dom","@pluginjs/utils","@pluginjs/decorator","@pluginjs/swipeable","@pluginjs/image-loader","@pluginjs/loader","@pluginjs/breakpoints"],t):(e=e||self)["@pluginjs/thumbnails"]=t(e.anime,e["@pluginjs/component"],e["@pluginjs/template"],e["@pluginjs/styled"],e["@pluginjs/classes"],e["@pluginjs/events"],e["@pluginjs/dom"],e["@pluginjs/utils"],e["@pluginjs/decorator"],e["@pluginjs/swipeable"],e["@pluginjs/image-loader"],e["@pluginjs/loader"],e["@pluginjs/breakpoints"])}(this,(function(e,t,i,s,n,r,a,o,l,c,u,h,p){"use strict";function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function g(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function v(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?m(Object(i),!0).forEach((function(t){g(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):m(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function E(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,s=y(e);if(t){var n=y(this).constructor;i=Reflect.construct(s,arguments,n)}else i=s.apply(this,arguments);return j(this,i)}}function O(e,t,i){return(O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var s=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(s){var n=Object.getOwnPropertyDescriptor(s,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var i=[],s=!0,n=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(i.push(a.value),!t||i.length!==t);s=!0);}catch(e){n=!0,r=e}finally{try{s||null==o.return||o.return()}finally{if(n)throw r}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return w(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return w(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,c=c&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c,u=u&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u,h=h&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h,p=p&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p;var S,A={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"};return l.themeable()(S=l.styleable({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(S=l.eventable(A)(S=l.stateable()(S=l.optionable({templates:{inner:function(){return'<div class="{classes.INNER}"></div>'},thumb:function(){return'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'}},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},!0)(S=l.register("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(S=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(S,t);var l,m,j,w=E(S);function S(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return d(this,S),(t=w.call(this,e)).setupOptions(i),t.distance=0,t.pos=0,t.current=null,t.dif=null,t.setupClasses(),t.setupStates(),t.initialize(),t}return l=S,(m=[{key:"initialize",value:function(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(A.READY))}},{key:"initBreakpoints",value:function(){if(p.init(),p.all().includes(this.options.breakpoint)){var e=this.options.breakpoint,t=this;p.is("".concat(e,"-"))&&n.addClass(this.classes.RESPONSIVE,this.element),p.to(e,{enter:function(){n.addClass(t.classes.RESPONSIVE,t.element)},leave:function(){n.removeClass(t.classes.RESPONSIVE,t.element)}})}}},{key:"parseHtml",value:function(){var e=this,t=[],i=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return i.length>0&&i.forEach((function(i){var r=a.closest(".".concat(e.classes.THUMB),i),l={src:i.getAttribute("src")||window.getComputedStyle(i)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};r&&(l.type=n.hasClass(e.classes.VIDEO,r)?"video":"image");var c=Object.entries(i.dataset).reduce((function(e,t){var i=D(t,2),s=i[0],n=i[1];try{var r=JSON.parse('{"data": '.concat(n.replace(/'/g,'"'),"}")).data;return v(v({},e),{},g({},s,r))}catch(t){return v(v({},e),{},g({},s,n))}}),{});l=o.deepMerge(l,c),t.push(l)})),t}},{key:"generate",value:function(){var e=this;n.addClass(this.classes.THUMBS,this.element),this.options.theme&&n.addClass(this.getThemeClass(),this.element),this.options.vertical&&n.addClass(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach((function(t,i){var s=e.getElement("thumb");"video"===t.type&&n.addClass(e.classes.VIDEO,s),a.setData("index",i,s),s.querySelector(".".concat(e.classes.IMAGE)).setAttribute("src",t.src),a.append(s,e.inner)})),this.element.innerHTML="",a.append(this.inner,this.element)}},{key:"initImageLoader",value:function(){var e=this;this.items.forEach((function(t){var i="";e.options.loader&&(i=h.of(a.query(".".concat(e.classes.LOADER),t),e.options.loader)).show(),u.of(t.querySelector(".".concat(e.classes.IMAGE))).on("loaded",(function(t){e.options.loader&&i.hide(),n.addClass(e.classes.LOADED,a.closest(".".concat(e.classes.THUMB),t))}))}))}},{key:"initSwipeable",value:function(){var e=this,t=this,i=function(){e.pos=e.swipeable.position[e.options.vertical?"y":"x"]};this.swipeable=c.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart:function(){t.enter("dragged")},onDecayend:function(){i()},onReboundend:function(){i()},onEnd:function(){i()}})}},{key:"getElement",value:function(e){var t,s=this.options.templates[e];return t=i.render(s.call(this),{classes:this.classes}),a.parseHTML(t)}},{key:"setDistance",value:function(e){this.wrapDistance=e?s.outerHeight(this.element):s.outerWidth(this.element),this.innerDistance=e?this.inner.scrollHeight:this.inner.scrollWidth}},{key:"setItemDistance",value:function(e){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[e?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=e?s.outerHeight(this.items[0]):s.outerWidth(this.items[0]))}},{key:"bind",value:function(){var e=this;r.bindEvent(this.eventName("click"),(function(t){if(e.is("dragged"))return e.leave("dragged"),!1;if(e.is("disable")||e.swipeable.is("paning"))return!1;var i=a.closest(".".concat(e.classes.THUMB),t.target);if(!i)return!1;var s=Number(a.getData("index",i));return e.go(s)}),this.element)}},{key:"unbind",value:function(){r.removeEvent(this.eventName(),this.element)}},{key:"getItemPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(t?this.distance/2:this.distance)-this.distance*(e+1)-this.gutter*e}},{key:"setPos",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.options.mode,a=0;if("full"===r){if(this.innerDistance>this.wrapDistance){var o=this.wrapDistance-this.innerDistance;if(null===this.current){var l=this.getItemPos(t);a=o<l?l:o}else if(this.current===this.length-1&&0===t)a=0;else if(0===this.current&&t===this.length-1)a=o;else{var c=this.pos;if(t>this.current){var u=c-this.distance-this.gutter;a=o<u?u:o}else if(t<this.current){var h=c+this.distance+this.gutter;a=h>0?0:h}}}}else"center"===r&&(a=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(t,!0));if(n){var p={targets:this.inner,easing:"linear",duration:300};p[i?"translateY":"translateX"]=a,e(p)}else s.setStyle({transform:"".concat(i?"translateY":"translateX","(").concat(a,"px)")},this.inner);this.pos=a}},{key:"resetPos",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==t){this.setItemDistance(this.options.vertical);var i=this.pos,n=this.wrapDistance-this.innerDistance,r=0;n>0||(null===this.dif&&(this.dif=n),"center"===this.options.mode?r=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((r=this.current===this.length-1?i+(n-this.dif):i)>0&&(r=0),r<n&&(r=n)),this.dif=n,s.setStyle({transform:"".concat(e?"translateY":"translateX","(").concat(r,"px)")},this.inner),this.pos=r)}}},{key:"go",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||e<0||e>this.length||e===this.current||(this.setPos(e,this.options.vertical,i),n.removeClass(this.classes.ACTIVE,this.items[this.current]),n.addClass(this.classes.ACTIVE,this.items[e]),this.current=e,t&&this.trigger(A.CHANGE))}},{key:"next",value:function(){this.is("disable")||(this.go(this.current+1),this.trigger(A.NEXT))}},{key:"prev",value:function(){this.is("disable")||(this.go(this.current-1),this.trigger(A.PREV))}},{key:"resize",value:function(){this.resetPos(this.options.vertical)}},{key:"enable",value:function(){this.is("disable")&&(n.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(A.ENABLE)}},{key:"disable",value:function(){this.is("disable")||(n.addClass(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(A.DISABLE)}},{key:"destroy",value:function(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&n.removeClass(this.classes.VERTICAL,this.element),this.options.theme&&n.removeClass(this.getThemeClass(),this.element),this.is("disabled")&&(n.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(A.DESTROY),O(y(S.prototype),"destroy",this).call(this)}}])&&f(l.prototype,m),j&&f(l,j),S}(t))||S)||S)||S)||S)||S)||S})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("animejs"),require("@pluginjs/component"),require("@pluginjs/template"),require("@pluginjs/styled"),require("@pluginjs/classes"),require("@pluginjs/events"),require("@pluginjs/dom"),require("@pluginjs/utils"),require("@pluginjs/decorator"),require("@pluginjs/swipeable"),require("@pluginjs/image-loader"),require("@pluginjs/loader"),require("@pluginjs/breakpoints")):"function"==typeof define&&define.amd?define(["animejs","@pluginjs/component","@pluginjs/template","@pluginjs/styled","@pluginjs/classes","@pluginjs/events","@pluginjs/dom","@pluginjs/utils","@pluginjs/decorator","@pluginjs/swipeable","@pluginjs/image-loader","@pluginjs/loader","@pluginjs/breakpoints"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["@pluginjs/thumbnails"]=t(e.anime,e["@pluginjs/component"],e["@pluginjs/template"],e["@pluginjs/styled"],e["@pluginjs/classes"],e["@pluginjs/events"],e["@pluginjs/dom"],e["@pluginjs/utils"],e["@pluginjs/decorator"],e["@pluginjs/swipeable"],e["@pluginjs/image-loader"],e["@pluginjs/loader"],e["@pluginjs/breakpoints"])}(this,(function(e,t,i,s,n,r,a,o,l,c,u,h,p){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),g=d(t),m=d(i),v=d(c),y=d(u),b=d(h),E=d(p);function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function D(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function w(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function S(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?w(Object(i),!0).forEach((function(t){D(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):w(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,s=A(e);if(t){var n=A(this).constructor;i=Reflect.construct(s,arguments,n)}else i=s.apply(this,arguments);return k(this,i)}}function C(e,t,i){return(C="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var s=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=A(e)););return e}(e,t);if(s){var n=Object.getOwnPropertyDescriptor(s,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var i=[],s=!0,n=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(s=(a=o.next()).done)&&(i.push(a.value),!t||i.length!==t);s=!0);}catch(e){n=!0,r=e}finally{try{s||null==o.return||o.return()}finally{if(n)throw r}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return T(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}var L,N={READY:"ready",ENABLE:"enable",DISABLE:"disable",DESTROY:"destroy",CHANGE:"change",PREV:"prev",NEXT:"next"};return l.themeable()(L=l.styleable({NAMESPACE:"pj-thumb",THEME:"{namespace}s--{theme}",THUMBS:"{namespace}s",INNER:"{namespace}s-inner",THUMB:"{namespace}",LOADER:"{namespace}-loader",LOADED:"{namespace}-loaded",VIDEO:"{namespace}-video",IMAGE:"{namespace}-img",VERTICAL:"{namespace}s-vertical",ACTIVE:"{namespace}-active",DISABLED:"{namespace}-disabled",RESPONSIVE:"{namespace}-responsive"})(L=l.eventable(N)(L=l.stateable()(L=l.optionable({templates:{inner:function(){return'<div class="{classes.INNER}"></div>'},thumb:function(){return'<div class="{classes.THUMB}"><div class="{classes.LOADER}"></div><img class="{classes.IMAGE}"></div>'}},data:"html",delegate:"img",vertical:!1,current:0,mode:"full",loader:{theme:"ring",color:"#000",size:"lg"},breakpoint:null},!0)(L=l.register("thumbnails",{methods:["enable","disable","destroy","next","prev","go"],dependencies:["anime"]})(L=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}(u,e);var t,i,l,c=P(u);function u(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return j(this,u),(t=c.call(this,e)).setupOptions(i),t.distance=0,t.pos=0,t.current=null,t.dif=null,t.setupClasses(),t.setupStates(),t.initialize(),t}return t=u,(i=[{key:"initialize",value:function(){!this.options.data||this.options.data.length<0||("function"!=typeof NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.options.breakpoint&&this.initBreakpoints(),this.data="html"===this.options.data?this.parseHtml():this.options.data,this.generate(),this.items=this.inner.querySelectorAll(".".concat(this.classes.THUMB)),this.setDistance(this.options.vertical),this.setItemDistance(this.options.vertical),this.go(this.options.current||0,!1,!1),this.initImageLoader(),this.initSwipeable(),this.bind(),this.enter("initialized"),this.trigger(N.READY))}},{key:"initBreakpoints",value:function(){if(E.default.init(),E.default.all().includes(this.options.breakpoint)){var e=this.options.breakpoint,t=this;E.default.is("".concat(e,"-"))&&n.addClass(this.classes.RESPONSIVE,this.element),E.default.to(e,{enter:function(){n.addClass(t.classes.RESPONSIVE,t.element)},leave:function(){n.removeClass(t.classes.RESPONSIVE,t.element)}})}}},{key:"parseHtml",value:function(){var e=this,t=[],i=this.element.querySelectorAll(this.options.delegate),s=new RegExp(/\((.+?)\)/);return i.length>0&&i.forEach((function(i){var r=a.closest(".".concat(e.classes.THUMB),i),l={src:i.getAttribute("src")||window.getComputedStyle(i)["background-image"].match(s)[1].replace(/'/g,"").replace(/"/g,"")};r&&(l.type=n.hasClass(e.classes.VIDEO,r)?"video":"image");var c=Object.entries(i.dataset).reduce((function(e,t){var i=R(t,2),s=i[0],n=i[1];try{var r=JSON.parse('{"data": '.concat(n.replace(/'/g,'"'),"}")).data;return S(S({},e),{},D({},s,r))}catch(t){return S(S({},e),{},D({},s,n))}}),{});l=o.deepMerge(l,c),t.push(l)})),t}},{key:"generate",value:function(){var e=this;n.addClass(this.classes.THUMBS,this.element),this.options.theme&&n.addClass(this.getThemeClass(),this.element),this.options.vertical&&n.addClass(this.classes.VERTICAL,this.element),this.inner=this.getElement("inner"),this.data.forEach((function(t,i){var s=e.getElement("thumb");"video"===t.type&&n.addClass(e.classes.VIDEO,s),a.setData("index",i,s),s.querySelector(".".concat(e.classes.IMAGE)).setAttribute("src",t.src),a.append(s,e.inner)})),this.element.innerHTML="",a.append(this.inner,this.element)}},{key:"initImageLoader",value:function(){var e=this;this.items.forEach((function(t){var i="";e.options.loader&&(i=b.default.of(a.query(".".concat(e.classes.LOADER),t),e.options.loader)).show(),y.default.of(t.querySelector(".".concat(e.classes.IMAGE))).on("loaded",(function(t){e.options.loader&&i.hide(),n.addClass(e.classes.LOADED,a.closest(".".concat(e.classes.THUMB),t))}))}))}},{key:"initSwipeable",value:function(){var e=this,t=this,i=function(){e.pos=e.swipeable.position[e.options.vertical?"y":"x"]};this.swipeable=v.default.of(this.inner,{rebound:!0,decay:!0,axis:this.options.vertical?"y":"x",reboundPos:"center"===this.options.mode?50:100,offset:"center"===this.options.mode?this.distance/2:0,onStart:function(){t.enter("dragged")},onDecayend:function(){i()},onReboundend:function(){i()},onEnd:function(){i()}})}},{key:"getElement",value:function(e){var t,i=this.options.templates[e];return t=m.default.render(i.call(this),{classes:this.classes}),a.parseHTML(t)}},{key:"setDistance",value:function(e){this.wrapDistance=e?s.outerHeight(this.element):s.outerWidth(this.element),this.innerDistance=e?this.inner.scrollHeight:this.inner.scrollWidth}},{key:"setItemDistance",value:function(e){this.length=this.items.length,this.distance=0,this.gutter=this.length>1?parseInt(window.getComputedStyle(this.items[1])[e?"margin-top":"margin-left"],10):0,this.length>0&&(this.distance=e?s.outerHeight(this.items[0]):s.outerWidth(this.items[0]))}},{key:"bind",value:function(){var e=this;r.bindEvent(this.eventName("click"),(function(t){if(e.is("dragged"))return e.leave("dragged"),!1;if(e.is("disable")||e.swipeable.is("paning"))return!1;var i=a.closest(".".concat(e.classes.THUMB),t.target);if(!i)return!1;var s=Number(a.getData("index",i));return e.go(s)}),this.element)}},{key:"unbind",value:function(){r.removeEvent(this.eventName(),this.element)}},{key:"getItemPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(t?this.distance/2:this.distance)-this.distance*(e+1)-this.gutter*e}},{key:"setPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.options.mode,r=0;if("full"===n){if(this.innerDistance>this.wrapDistance){var a=this.wrapDistance-this.innerDistance;if(null===this.current){var o=this.getItemPos(e);r=a<o?o:a}else if(this.current===this.length-1&&0===e)r=0;else if(0===this.current&&e===this.length-1)r=a;else{var l=this.pos;if(e>this.current){var c=l-this.distance-this.gutter;r=a<c?c:a}else if(e<this.current){var u=l+this.distance+this.gutter;r=u>0?0:u}}}}else"center"===n&&(r=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(e,!0));if(i){var h={targets:this.inner,easing:"linear",duration:300};h[t?"translateY":"translateX"]=r,f.default(h)}else s.setStyle({transform:"".concat(t?"translateY":"translateX","(").concat(r,"px)")},this.inner);this.pos=r}},{key:"resetPos",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.wrapDistance;if(this.setDistance(this.options.vertical),this.wrapDistance!==t){this.setItemDistance(this.options.vertical);var i=this.pos,n=this.wrapDistance-this.innerDistance,r=0;n>0||(null===this.dif&&(this.dif=n),"center"===this.options.mode?r=Math.min(this.wrapDistance,this.innerDistance)/2+this.getItemPos(this.current,!0):((r=this.current===this.length-1?i+(n-this.dif):i)>0&&(r=0),r<n&&(r=n)),this.dif=n,s.setStyle({transform:"".concat(e?"translateY":"translateX","(").concat(r,"px)")},this.inner),this.pos=r)}}},{key:"go",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.is("disable")||e<0||e>this.length||e===this.current||(this.setPos(e,this.options.vertical,i),n.removeClass(this.classes.ACTIVE,this.items[this.current]),n.addClass(this.classes.ACTIVE,this.items[e]),this.current=e,t&&this.trigger(N.CHANGE))}},{key:"next",value:function(){this.is("disable")||(this.go(this.current+1),this.trigger(N.NEXT))}},{key:"prev",value:function(){this.is("disable")||(this.go(this.current-1),this.trigger(N.PREV))}},{key:"resize",value:function(){this.resetPos(this.options.vertical)}},{key:"enable",value:function(){this.is("disable")&&(n.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1,this.leave("disable")),this.trigger(N.ENABLE)}},{key:"disable",value:function(){this.is("disable")||(n.addClass(this.classes.DISABLED,this.element),this.element.disable=!0,this.enter("disable")),this.trigger(N.DISABLE)}},{key:"destroy",value:function(){this.is("initialized")&&(this.unbind(),!0===this.options.vertical&&n.removeClass(this.classes.VERTICAL,this.element),this.options.theme&&n.removeClass(this.getThemeClass(),this.element),this.is("disabled")&&(n.removeClass(this.classes.DISABLED,this.element),this.element.disable=!1),this.leave("initialized")),this.trigger(N.DESTROY),C(A(u.prototype),"destroy",this).call(this)}}])&&O(t.prototype,i),l&&O(t,l),u}(g.default))||L)||L)||L)||L)||L)||L})); |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "0.8.6", | ||
"version": "0.8.7", | ||
"category": "ui", | ||
@@ -41,25 +41,25 @@ "main": "dist/thumbnails.common.js", | ||
"dependencies": { | ||
"@pluginjs/breakpoints": "^0.8.4", | ||
"@pluginjs/classes": "^0.8.4", | ||
"@pluginjs/component": "^0.8.4", | ||
"@pluginjs/decorator": "^0.8.5", | ||
"@pluginjs/dom": "^0.8.4", | ||
"@pluginjs/events": "^0.8.5", | ||
"@pluginjs/factory": "^0.8.4", | ||
"@pluginjs/image-loader": "^0.8.4", | ||
"@pluginjs/is": "^0.8.4", | ||
"@pluginjs/loader": "^0.8.5", | ||
"@pluginjs/styled": "^0.8.4", | ||
"@pluginjs/styles": "^0.8.3", | ||
"@pluginjs/swipeable": "^0.8.5", | ||
"@pluginjs/template": "^0.8.4", | ||
"@pluginjs/utils": "^0.8.4", | ||
"@pluginjs/breakpoints": "^0.8.5", | ||
"@pluginjs/classes": "^0.8.5", | ||
"@pluginjs/component": "^0.8.5", | ||
"@pluginjs/decorator": "^0.8.6", | ||
"@pluginjs/dom": "^0.8.5", | ||
"@pluginjs/events": "^0.8.6", | ||
"@pluginjs/factory": "^0.8.5", | ||
"@pluginjs/image-loader": "^0.8.5", | ||
"@pluginjs/is": "^0.8.5", | ||
"@pluginjs/loader": "^0.8.6", | ||
"@pluginjs/styled": "^0.8.5", | ||
"@pluginjs/styles": "^0.8.4", | ||
"@pluginjs/swipeable": "^0.8.6", | ||
"@pluginjs/template": "^0.8.5", | ||
"@pluginjs/utils": "^0.8.5", | ||
"animejs": "*" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.10.2", | ||
"@pluginjs/browserslist-config": "^1.3.1", | ||
"@pluginjs/cli": "^0.8.1", | ||
"@rollup/plugin-commonjs": "^12.0.0", | ||
"@rollup/plugin-node-resolve": "^8.0.0", | ||
"@babel/core": "^7.12.10", | ||
"@pluginjs/browserslist-config": "^1.3.2", | ||
"@pluginjs/cli": "^0.8.2", | ||
"@rollup/plugin-commonjs": "^17.1.0", | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"babel-jest": "*", | ||
@@ -69,3 +69,3 @@ "jest": "*", | ||
"rename": "^1.0.4", | ||
"rollup": "^2.12.0", | ||
"rollup": "^2.38.1", | ||
"rollup-plugin-babel": "*", | ||
@@ -85,3 +85,3 @@ "rollup-plugin-terser": "*" | ||
}, | ||
"gitHead": "a81715de5d8c4934f801ef05b6a744016944904f" | ||
"gitHead": "e0247ab4b5e2026b77a390619f2b96bac30609c6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
110342
2270
Updated@pluginjs/breakpoints@^0.8.5
Updated@pluginjs/classes@^0.8.5
Updated@pluginjs/component@^0.8.5
Updated@pluginjs/decorator@^0.8.6
Updated@pluginjs/dom@^0.8.5
Updated@pluginjs/events@^0.8.6
Updated@pluginjs/factory@^0.8.5
Updated@pluginjs/is@^0.8.5
Updated@pluginjs/loader@^0.8.6
Updated@pluginjs/styled@^0.8.5
Updated@pluginjs/styles@^0.8.4
Updated@pluginjs/swipeable@^0.8.6
Updated@pluginjs/template@^0.8.5
Updated@pluginjs/utils@^0.8.5