From b11c86156a48386299e7647056a638bce9c0530a Mon Sep 17 00:00:00 2001 From: lorenzodianni Date: Thu, 29 Dec 2022 02:43:51 +0100 Subject: [PATCH] chore(version): 10.0.0 --- CHANGELOG.md | 9 ++ lib/amd/sidebarjs.js | 145 ++++++++------------------------ lib/amd/sidebarjs.min.js | 2 +- lib/cjs/sidebarjs.js | 141 ++++++++----------------------- lib/cjs/sidebarjs.min.js | 2 +- lib/esm/sidebarjs.js | 12 +-- lib/sidebarjs.css | 149 +++++++++++++++++++-------------- lib/sidebarjs.min.css | 2 +- lib/src/sidebar.core.d.ts | 2 +- lib/src/sidebar.core.js | 4 +- lib/src/sidebar.core.js.map | 2 +- lib/src/sidebar.element.js | 6 +- lib/src/sidebar.element.js.map | 2 +- lib/umd/sidebarjs.js | 145 ++++++++------------------------ lib/umd/sidebarjs.min.js | 2 +- package.json | 2 +- 16 files changed, 221 insertions(+), 406 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 364e2cb..489acc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [10.0.0](https://github.com/SidebarJS/sidebarjs/compare/9.0.0...10.0.0) (2022-12-29) + + +### Features + +* update all deps and change build process ([10ca7f0](https://github.com/SidebarJS/sidebarjs/commit/10ca7f0603d17f9b351c8e95407c69ed9c14c898)) + + + # [9.0.0](https://github.com/SidebarJS/sidebarjs/compare/8.0.0...9.0.0) (2021-07-20) diff --git a/lib/amd/sidebarjs.js b/lib/amd/sidebarjs.js index 363c862..09f5390 100644 --- a/lib/amd/sidebarjs.js +++ b/lib/amd/sidebarjs.js @@ -1,48 +1,56 @@ /* * SidebarJS - * Version 9.0.0 + * Version 10.0.0 * https://github.com/SidebarJS/sidebarjs#readme */ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function _typeof(obj) { "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); return Constructor; } + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); + } + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); + } var SIDEBARJS = 'sidebarjs'; var SIDEBARJS_FALLBACK_NAME = ''; @@ -51,11 +59,7 @@ define(['exports'], function (exports) { 'use strict'; var SIDEBARJS_TRANSITION_END = 'sidebarjs--transition-end'; var IS_VISIBLE = "".concat(SIDEBARJS, "--is-visible"); var IS_MOVING = "".concat(SIDEBARJS, "--is-moving"); - var POSITIONS = ["left" - /* Left */ - , "right" - /* Right */ - ]; + var POSITIONS = ["left" /* SidebarPosition.Left */, "right" /* SidebarPosition.Right */]; var EVENT_LISTENER_OPTIONS = { passive: true }; @@ -67,9 +71,7 @@ define(['exports'], function (exports) { 'use strict'; documentMinSwipeX: 10, documentSwipeRange: 40, responsive: false, - position: "left" - /* Left */ - , + position: "left" /* SidebarPosition.Left */, backdropOpacity: 0.3 }; function isStyleMapSupported() { @@ -95,7 +97,6 @@ define(['exports'], function (exports) { 'use strict'; for (var i = 0; i < ELEMENT_ACTIONS.length; i++) { var action = ELEMENT_ACTIONS[i]; var elements = document.querySelectorAll("[".concat(SIDEBARJS, "-").concat(action, "=\"").concat(sidebarName, "\"]")); - for (var j = 0; j < elements.length; j++) { func(elements[j], action); } @@ -113,112 +114,82 @@ define(['exports'], function (exports) { 'use strict'; var SidebarElement = /*#__PURE__*/function () { function SidebarElement() { var _this = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - _classCallCheck(this, SidebarElement); - this.toggle = function () { _this.isVisible() ? _this.close() : _this.open(); }; - this.open = function () { _this.addComponentClass(IS_VISIBLE); - _this.setBackdropOpacity(_this.backdropOpacity); }; - this.close = function () { _this.removeComponentClass(IS_VISIBLE); - _this.clearStyle(_this.backdrop); }; - this._onTouchStart = function (e) { _this.initialTouch = e.touches[0].pageX; }; - this._onTouchMove = function (e) { var swipeDirection = -(_this.initialTouch - e.touches[0].clientX); var sidebarMovement = _this.container.clientWidth + (_this.hasLeftPosition() ? swipeDirection : -swipeDirection); - if (sidebarMovement <= _this.container.clientWidth) { _this.touchMoveSidebar = Math.abs(swipeDirection); - _this.moveSidebar(swipeDirection); } }; - this._onTouchEnd = function () { _this.removeComponentClass(IS_MOVING); - _this.clearStyle(_this.container); - _this.clearStyle(_this.backdrop); - _this.touchMoveSidebar > _this.container.clientWidth / 3.5 ? _this.close() : _this.open(); _this.initialTouch = null; _this.touchMoveSidebar = null; }; - this._onSwipeOpenStart = function (e) { if (targetElementIsBackdrop(e)) { return; } - var touchPositionX = e.touches[0].clientX; var documentTouch = _this.hasLeftPosition() ? touchPositionX : document.body.clientWidth - touchPositionX; - if (documentTouch < _this.documentSwipeRange) { _this._onTouchStart(e); } }; - this._onSwipeOpenMove = function (e) { if (!targetElementIsBackdrop(e) && _this.initialTouch && !_this.isVisible()) { var documentSwiped = e.touches[0].clientX - _this.initialTouch; - var hasLeftPosition = _this.hasLeftPosition(); - var swipeX = hasLeftPosition ? documentSwiped : -documentSwiped; var sidebarMovement = _this.container.clientWidth - swipeX; - if (sidebarMovement > 0 && swipeX >= _this.documentMinSwipeX) { _this.openMovement = hasLeftPosition ? -sidebarMovement : sidebarMovement; - _this.moveSidebar(_this.openMovement); } } }; - this._onSwipeOpenEnd = function () { if (_this.openMovement) { _this.openMovement = null; - _this._onTouchEnd(); } }; - this._onTransitionStart = function () { var _this$getTransitionTy = _this.getTransitionType(), - open = _this$getTransitionTy.open, - close = _this$getTransitionTy.close; - + open = _this$getTransitionTy.open, + close = _this$getTransitionTy.close; if (open || close) { _this.toggleTransitionClass(true); } }; - this._onTransitionEnd = function () { var _this$getTransitionTy2 = _this.getTransitionType(), - open = _this$getTransitionTy2.open, - close = _this$getTransitionTy2.close, - isVisible = _this$getTransitionTy2.isVisible; - + open = _this$getTransitionTy2.open, + close = _this$getTransitionTy2.close, + isVisible = _this$getTransitionTy2.isVisible; if (open || close) { _this.toggleTransitionClass(false); } - if (open) { _this._wasVisible = true; shouldInvokeFunction(_this._emitOnOpen); @@ -226,14 +197,12 @@ define(['exports'], function (exports) { 'use strict'; _this._wasVisible = false; shouldInvokeFunction(_this._emitOnClose); } - if (_this._emitOnChangeVisibility) { _this._emitOnChangeVisibility({ isVisible: isVisible }); } }; - this.nativeGestures = new Map([[TOUCH_START, this._onTouchStart], [TOUCH_MOVE, this._onTouchMove], [TOUCH_END, this._onTouchEnd]]); this.nativeOpenGestures = new Map([[TOUCH_START, this._onSwipeOpenStart], [TOUCH_MOVE, this._onSwipeOpenMove], [TOUCH_END, this._onSwipeOpenEnd]]); var config = Object.assign(Object.assign({}, DEFAULT_CONFIG), options); @@ -253,7 +222,6 @@ define(['exports'], function (exports) { 'use strict'; this._emitOnOpen = config.onOpen; this._emitOnClose = config.onClose; this._emitOnChangeVisibility = config.onChangeVisibility; - if (!hasCustomTransclude) { try { this.transcludeContent(); @@ -261,19 +229,15 @@ define(['exports'], function (exports) { 'use strict'; throw new Error('You must define an element with [sidebarjs] attribute'); } } - this.setSwipeGestures(true); - if (this.responsive || this.mainContent) { this.setResponsive(); } - this.setPosition(config.position); this.addAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.addTransitionListener(); this.backdrop.addEventListener('click', this.close, EVENT_LISTENER_OPTIONS); } - _createClass(SidebarElement, [{ key: "isVisible", value: function isVisible() { @@ -283,7 +247,6 @@ define(['exports'], function (exports) { 'use strict'; key: "destroy", value: function destroy() { var _this2 = this; - this.removeNativeGestures(); this.container.removeEventListener('transitionstart', this._onTransitionStart); this.container.removeEventListener('transitionend', this._onTransitionEnd); @@ -291,11 +254,9 @@ define(['exports'], function (exports) { 'use strict'; this.removeNativeOpenGestures(); this.removeAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.removeComponentClassPosition(); - while (this.container.firstElementChild) { this.component.appendChild(this.container.firstElementChild); } - this.component.removeChild(this.container); this.component.removeChild(this.backdrop); Object.keys(this).forEach(function (key) { @@ -306,19 +267,14 @@ define(['exports'], function (exports) { 'use strict'; key: "setPosition", value: function setPosition(position) { var _this3 = this; - this.addComponentClass(IS_MOVING); - this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" - /* Left */ - ; + this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* SidebarPosition.Left */; var resetMainContent = (document.querySelectorAll("[".concat(SIDEBARJS, "]")) || []).length === 1; this.removeComponentClassPosition(resetMainContent); this.addComponentClass("".concat(SIDEBARJS, "--").concat(this.position)); - if (this.responsive && this.mainContent) { this.mainContent.classList.add("".concat(SIDEBARJS_CONTENT, "--").concat(this.position)); } - setTimeout(function () { return _this3.component && _this3.removeComponentClass(IS_MOVING); }, 200); @@ -327,7 +283,6 @@ define(['exports'], function (exports) { 'use strict'; key: "addAttrsEventsListeners", value: function addAttrsEventsListeners(sidebarName) { var _this4 = this; - forEachActionElement(sidebarName, function (element, action) { if (!elemHasListener(element)) { element.addEventListener('click', _this4[action], EVENT_LISTENER_OPTIONS); @@ -339,7 +294,6 @@ define(['exports'], function (exports) { 'use strict'; key: "removeAttrsEventsListeners", value: function removeAttrsEventsListeners(sidebarName) { var _this5 = this; - forEachActionElement(sidebarName, function (element, action) { if (elemHasListener(element)) { element.removeEventListener('click', _this5[action]); @@ -353,10 +307,8 @@ define(['exports'], function (exports) { 'use strict'; if (typeof value !== 'boolean') { throw new Error("You provided a ".concat(_typeof(value), " value but setSwipeGestures needs a boolean value.")); } - if (this.nativeSwipe) { value ? this.addNativeGestures() : this.removeNativeGestures(); - if (this.nativeSwipeOpen) { value ? this.addNativeOpenGestures() : this.removeNativeOpenGestures(); } @@ -392,7 +344,6 @@ define(['exports'], function (exports) { 'use strict'; value: function removeComponentClassPosition(resetMainContent) { for (var i = 0; i < POSITIONS.length; i++) { this.removeComponentClass("".concat(SIDEBARJS, "--").concat(POSITIONS[i])); - if (resetMainContent && this.mainContent) { this.mainContent.classList.remove("".concat(SIDEBARJS_CONTENT, "--").concat(POSITIONS[i])); } @@ -401,16 +352,12 @@ define(['exports'], function (exports) { 'use strict'; }, { key: "hasLeftPosition", value: function hasLeftPosition() { - return this.position === "left" - /* Left */ - ; + return this.position === "left" /* SidebarPosition.Left */; } }, { key: "hasRightPosition", value: function hasRightPosition() { - return this.position === "right" - /* Right */ - ; + return this.position === "right" /* SidebarPosition.Right */; } }, { key: "transcludeContent", @@ -418,11 +365,9 @@ define(['exports'], function (exports) { 'use strict'; while (this.component.firstChild) { this.container.appendChild(this.component.firstChild); } - while (this.component.firstChild) { this.component.removeChild(this.component.firstChild); } - this.component.appendChild(this.container); this.component.appendChild(this.backdrop); } @@ -430,7 +375,6 @@ define(['exports'], function (exports) { 'use strict'; key: "addNativeGestures", value: function addNativeGestures() { var _this6 = this; - this.nativeGestures.forEach(function (action, event) { _this6.component.addEventListener(event, action, EVENT_LISTENER_OPTIONS); }); @@ -439,7 +383,6 @@ define(['exports'], function (exports) { 'use strict'; key: "removeNativeGestures", value: function removeNativeGestures() { var _this7 = this; - this.nativeGestures.forEach(function (action, event) { _this7.component.removeEventListener(event, action); }); @@ -483,11 +426,9 @@ define(['exports'], function (exports) { 'use strict'; if (!this.responsive && this.mainContent) { throw new Error("You provide a [".concat(SIDEBARJS_CONTENT, "] element without set {responsive: true}")); } - if (this.responsive && !this.mainContent) { throw new Error("You have set {responsive: true} without provide a [".concat(SIDEBARJS_CONTENT, "] element")); } - this.addComponentClass('sidebarjs--responsive'); } }, { @@ -497,7 +438,6 @@ define(['exports'], function (exports) { 'use strict'; el.attributeStyleMap.set(prop, val); } else { el.style[prop] = val; - if (vendorify) { var vendor = 'webkit' + prop.charAt(0).toUpperCase() + prop.slice(1); el.style[vendor] = val; @@ -529,17 +469,14 @@ define(['exports'], function (exports) { 'use strict'; this.component.classList.toggle(className, force); } }]); - return SidebarElement; }(); var SidebarService = /*#__PURE__*/function () { function SidebarService() { _classCallCheck(this, SidebarService); - this.instances = {}; } - _createClass(SidebarService, [{ key: "fallbackName", value: function fallbackName(sidebarName) { @@ -554,7 +491,6 @@ define(['exports'], function (exports) { 'use strict'; key: "create", value: function create(options) { var _a; - var name = this.fallbackName((_a = options === null || options === void 0 ? void 0 : options.component) === null || _a === void 0 ? void 0 : _a.getAttribute(SIDEBARJS)); this.instances[name] = new SidebarElement(options); return this.instances[name]; @@ -563,35 +499,30 @@ define(['exports'], function (exports) { 'use strict'; key: "open", value: function open(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.open(); } }, { key: "close", value: function close(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.close(); } }, { key: "toggle", value: function toggle(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.toggle(); } }, { key: "isVisible", value: function isVisible(sidebarName) { var _a; - return !!((_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.isVisible()); } }, { key: "setPosition", value: function setPosition(position, sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.setPosition(position); } }, { @@ -603,7 +534,6 @@ define(['exports'], function (exports) { 'use strict'; key: "destroy", value: function destroy(sidebarName) { var name = this.fallbackName(sidebarName); - if (this.instances[name]) { this.instances[name].destroy(); this.instances[name] = null; @@ -611,13 +541,10 @@ define(['exports'], function (exports) { 'use strict'; } } }]); - return SidebarService; }(); exports.SidebarElement = SidebarElement; exports.SidebarService = SidebarService; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/lib/amd/sidebarjs.min.js b/lib/amd/sidebarjs.min.js index d41ca42..01e20db 100644 --- a/lib/amd/sidebarjs.min.js +++ b/lib/amd/sidebarjs.min.js @@ -1 +1 @@ -define(["exports"],(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),this.toggle=function(){e.isVisible()?e.close():e.open()},this.open=function(){e.addComponentClass(r),e.setBackdropOpacity(e.backdropOpacity)},this.close=function(){e.removeComponentClass(r),e.clearStyle(e.backdrop)},this._onTouchStart=function(t){e.initialTouch=t.touches[0].pageX},this._onTouchMove=function(t){var n=-(e.initialTouch-t.touches[0].clientX);e.container.clientWidth+(e.hasLeftPosition()?n:-n)<=e.container.clientWidth&&(e.touchMoveSidebar=Math.abs(n),e.moveSidebar(n))},this._onTouchEnd=function(){e.removeComponentClass(c),e.clearStyle(e.container),e.clearStyle(e.backdrop),e.touchMoveSidebar>e.container.clientWidth/3.5?e.close():e.open(),e.initialTouch=null,e.touchMoveSidebar=null},this._onSwipeOpenStart=function(t){if(!S(t)){var n=t.touches[0].clientX;(e.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=e.documentMinSwipeX&&(e.openMovement=i?-s:s,e.moveSidebar(e.openMovement))}},this._onSwipeOpenEnd=function(){e.openMovement&&(e.openMovement=null,e._onTouchEnd())},this._onTransitionStart=function(){var t=e.getTransitionType(),n=t.open,i=t.close;(n||i)&&e.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var t=e.getTransitionType(),n=t.open,i=t.close,o=t.isVisible;(n||i)&&e.toggleTransitionClass(!1),n?(e._wasVisible=!0,g(e._emitOnOpen)):i&&(e._wasVisible=!1,g(e._emitOnClose)),e._emitOnChangeVisibility&&e._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([[h,this._onTouchStart],[p,this._onTouchMove],[v,this._onTouchEnd]]),this.nativeOpenGestures=new Map([[h,this._onSwipeOpenStart],[p,this._onSwipeOpenMove],[v,this._onSwipeOpenEnd]]);var o=Object.assign(Object.assign({},m),i),a=o.container&&o.backdrop;if(this.component=o.component||document.querySelector("[".concat(s,"]")),this.container=a?o.container:y("".concat(s,"-container")),this.backdrop=a?o.backdrop:y("".concat(s,"-backdrop")),this.documentMinSwipeX=o.documentMinSwipeX,this.documentSwipeRange=o.documentSwipeRange,this.nativeSwipe=!1!==o.nativeSwipe,this.nativeSwipeOpen=!1!==o.nativeSwipeOpen,this.isStyleMapSupported=f(),this.responsive=Boolean(o.responsive),this.mainContent=C(o.mainContent),this.backdropOpacity=o.backdropOpacity,this.backdropOpacityRatio=1/o.backdropOpacity,this._emitOnOpen=o.onOpen,this._emitOnClose=o.onClose,this._emitOnChangeVisibility=o.onChangeVisibility,!a)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(o.position),this.addAttrsEventsListeners(this.component.getAttribute(s)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,u)}return o(t,[{key:"isVisible",value:function(){return this.component.classList.contains(r)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(s)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(c),this.position=l.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(s,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(s,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat(a,"--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(c)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;k(t,(function(t,n){b(t)||(t.addEventListener("click",e[n],u),b(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;k(t,(function(t,n){b(t)&&(t.removeEventListener("click",e[n]),b(t,!1))}))}},{key:"setSwipeGestures",value:function(t){if("boolean"!=typeof t)throw new Error("You provided a ".concat(e(t)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(t?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(t?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,u),this.container.addEventListener("transitionend",this._onTransitionEnd,u)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),this.toggle=function(){e.isVisible()?e.close():e.open()},this.open=function(){e.addComponentClass(r),e.setBackdropOpacity(e.backdropOpacity)},this.close=function(){e.removeComponentClass(r),e.clearStyle(e.backdrop)},this._onTouchStart=function(t){e.initialTouch=t.touches[0].pageX},this._onTouchMove=function(t){var n=-(e.initialTouch-t.touches[0].clientX);e.container.clientWidth+(e.hasLeftPosition()?n:-n)<=e.container.clientWidth&&(e.touchMoveSidebar=Math.abs(n),e.moveSidebar(n))},this._onTouchEnd=function(){e.removeComponentClass(c),e.clearStyle(e.container),e.clearStyle(e.backdrop),e.touchMoveSidebar>e.container.clientWidth/3.5?e.close():e.open(),e.initialTouch=null,e.touchMoveSidebar=null},this._onSwipeOpenStart=function(t){if(!k(t)){var n=t.touches[0].clientX;(e.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=e.documentMinSwipeX&&(e.openMovement=i?-s:s,e.moveSidebar(e.openMovement))}},this._onSwipeOpenEnd=function(){e.openMovement&&(e.openMovement=null,e._onTouchEnd())},this._onTransitionStart=function(){var t=e.getTransitionType(),n=t.open,i=t.close;(n||i)&&e.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var t=e.getTransitionType(),n=t.open,i=t.close,o=t.isVisible;(n||i)&&e.toggleTransitionClass(!1),n?(e._wasVisible=!0,g(e._emitOnOpen)):i&&(e._wasVisible=!1,g(e._emitOnClose)),e._emitOnChangeVisibility&&e._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([[h,this._onTouchStart],[p,this._onTouchMove],[v,this._onTouchEnd]]),this.nativeOpenGestures=new Map([[h,this._onSwipeOpenStart],[p,this._onSwipeOpenMove],[v,this._onSwipeOpenEnd]]);var o=Object.assign(Object.assign({},m),i),a=o.container&&o.backdrop;if(this.component=o.component||document.querySelector("[".concat(s,"]")),this.container=a?o.container:y("".concat(s,"-container")),this.backdrop=a?o.backdrop:y("".concat(s,"-backdrop")),this.documentMinSwipeX=o.documentMinSwipeX,this.documentSwipeRange=o.documentSwipeRange,this.nativeSwipe=!1!==o.nativeSwipe,this.nativeSwipeOpen=!1!==o.nativeSwipeOpen,this.isStyleMapSupported=f(),this.responsive=Boolean(o.responsive),this.mainContent=C(o.mainContent),this.backdropOpacity=o.backdropOpacity,this.backdropOpacityRatio=1/o.backdropOpacity,this._emitOnOpen=o.onOpen,this._emitOnClose=o.onClose,this._emitOnChangeVisibility=o.onChangeVisibility,!a)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(o.position),this.addAttrsEventsListeners(this.component.getAttribute(s)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,u)}return o(t,[{key:"isVisible",value:function(){return this.component.classList.contains(r)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(s)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(c),this.position=l.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(s,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(s,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat(a,"--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(c)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;S(t,(function(t,n){b(t)||(t.addEventListener("click",e[n],u),b(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;S(t,(function(t,n){b(t)&&(t.removeEventListener("click",e[n]),b(t,!1))}))}},{key:"setSwipeGestures",value:function(t){if("boolean"!=typeof t)throw new Error("You provided a ".concat(e(t)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(t?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(t?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,u),this.container.addEventListener("transitionend",this._onTransitionEnd,u)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e 0 && arguments[0] !== undefined ? arguments[0] : {}; - _classCallCheck(this, SidebarElement); - this.toggle = function () { _this.isVisible() ? _this.close() : _this.open(); }; - this.open = function () { _this.addComponentClass(IS_VISIBLE); - _this.setBackdropOpacity(_this.backdropOpacity); }; - this.close = function () { _this.removeComponentClass(IS_VISIBLE); - _this.clearStyle(_this.backdrop); }; - this._onTouchStart = function (e) { _this.initialTouch = e.touches[0].pageX; }; - this._onTouchMove = function (e) { var swipeDirection = -(_this.initialTouch - e.touches[0].clientX); var sidebarMovement = _this.container.clientWidth + (_this.hasLeftPosition() ? swipeDirection : -swipeDirection); - if (sidebarMovement <= _this.container.clientWidth) { _this.touchMoveSidebar = Math.abs(swipeDirection); - _this.moveSidebar(swipeDirection); } }; - this._onTouchEnd = function () { _this.removeComponentClass(IS_MOVING); - _this.clearStyle(_this.container); - _this.clearStyle(_this.backdrop); - _this.touchMoveSidebar > _this.container.clientWidth / 3.5 ? _this.close() : _this.open(); _this.initialTouch = null; _this.touchMoveSidebar = null; }; - this._onSwipeOpenStart = function (e) { if (targetElementIsBackdrop(e)) { return; } - var touchPositionX = e.touches[0].clientX; var documentTouch = _this.hasLeftPosition() ? touchPositionX : document.body.clientWidth - touchPositionX; - if (documentTouch < _this.documentSwipeRange) { _this._onTouchStart(e); } }; - this._onSwipeOpenMove = function (e) { if (!targetElementIsBackdrop(e) && _this.initialTouch && !_this.isVisible()) { var documentSwiped = e.touches[0].clientX - _this.initialTouch; - var hasLeftPosition = _this.hasLeftPosition(); - var swipeX = hasLeftPosition ? documentSwiped : -documentSwiped; var sidebarMovement = _this.container.clientWidth - swipeX; - if (sidebarMovement > 0 && swipeX >= _this.documentMinSwipeX) { _this.openMovement = hasLeftPosition ? -sidebarMovement : sidebarMovement; - _this.moveSidebar(_this.openMovement); } } }; - this._onSwipeOpenEnd = function () { if (_this.openMovement) { _this.openMovement = null; - _this._onTouchEnd(); } }; - this._onTransitionStart = function () { var _this$getTransitionTy = _this.getTransitionType(), - open = _this$getTransitionTy.open, - close = _this$getTransitionTy.close; - + open = _this$getTransitionTy.open, + close = _this$getTransitionTy.close; if (open || close) { _this.toggleTransitionClass(true); } }; - this._onTransitionEnd = function () { var _this$getTransitionTy2 = _this.getTransitionType(), - open = _this$getTransitionTy2.open, - close = _this$getTransitionTy2.close, - isVisible = _this$getTransitionTy2.isVisible; - + open = _this$getTransitionTy2.open, + close = _this$getTransitionTy2.close, + isVisible = _this$getTransitionTy2.isVisible; if (open || close) { _this.toggleTransitionClass(false); } - if (open) { _this._wasVisible = true; shouldInvokeFunction(_this._emitOnOpen); @@ -228,14 +197,12 @@ var SidebarElement = /*#__PURE__*/function () { _this._wasVisible = false; shouldInvokeFunction(_this._emitOnClose); } - if (_this._emitOnChangeVisibility) { _this._emitOnChangeVisibility({ isVisible: isVisible }); } }; - this.nativeGestures = new Map([[TOUCH_START, this._onTouchStart], [TOUCH_MOVE, this._onTouchMove], [TOUCH_END, this._onTouchEnd]]); this.nativeOpenGestures = new Map([[TOUCH_START, this._onSwipeOpenStart], [TOUCH_MOVE, this._onSwipeOpenMove], [TOUCH_END, this._onSwipeOpenEnd]]); var config = Object.assign(Object.assign({}, DEFAULT_CONFIG), options); @@ -255,7 +222,6 @@ var SidebarElement = /*#__PURE__*/function () { this._emitOnOpen = config.onOpen; this._emitOnClose = config.onClose; this._emitOnChangeVisibility = config.onChangeVisibility; - if (!hasCustomTransclude) { try { this.transcludeContent(); @@ -263,19 +229,15 @@ var SidebarElement = /*#__PURE__*/function () { throw new Error('You must define an element with [sidebarjs] attribute'); } } - this.setSwipeGestures(true); - if (this.responsive || this.mainContent) { this.setResponsive(); } - this.setPosition(config.position); this.addAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.addTransitionListener(); this.backdrop.addEventListener('click', this.close, EVENT_LISTENER_OPTIONS); } - _createClass(SidebarElement, [{ key: "isVisible", value: function isVisible() { @@ -285,7 +247,6 @@ var SidebarElement = /*#__PURE__*/function () { key: "destroy", value: function destroy() { var _this2 = this; - this.removeNativeGestures(); this.container.removeEventListener('transitionstart', this._onTransitionStart); this.container.removeEventListener('transitionend', this._onTransitionEnd); @@ -293,11 +254,9 @@ var SidebarElement = /*#__PURE__*/function () { this.removeNativeOpenGestures(); this.removeAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.removeComponentClassPosition(); - while (this.container.firstElementChild) { this.component.appendChild(this.container.firstElementChild); } - this.component.removeChild(this.container); this.component.removeChild(this.backdrop); Object.keys(this).forEach(function (key) { @@ -308,19 +267,14 @@ var SidebarElement = /*#__PURE__*/function () { key: "setPosition", value: function setPosition(position) { var _this3 = this; - this.addComponentClass(IS_MOVING); - this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" - /* Left */ - ; + this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* SidebarPosition.Left */; var resetMainContent = (document.querySelectorAll("[".concat(SIDEBARJS, "]")) || []).length === 1; this.removeComponentClassPosition(resetMainContent); this.addComponentClass("".concat(SIDEBARJS, "--").concat(this.position)); - if (this.responsive && this.mainContent) { this.mainContent.classList.add("".concat(SIDEBARJS_CONTENT, "--").concat(this.position)); } - setTimeout(function () { return _this3.component && _this3.removeComponentClass(IS_MOVING); }, 200); @@ -329,7 +283,6 @@ var SidebarElement = /*#__PURE__*/function () { key: "addAttrsEventsListeners", value: function addAttrsEventsListeners(sidebarName) { var _this4 = this; - forEachActionElement(sidebarName, function (element, action) { if (!elemHasListener(element)) { element.addEventListener('click', _this4[action], EVENT_LISTENER_OPTIONS); @@ -341,7 +294,6 @@ var SidebarElement = /*#__PURE__*/function () { key: "removeAttrsEventsListeners", value: function removeAttrsEventsListeners(sidebarName) { var _this5 = this; - forEachActionElement(sidebarName, function (element, action) { if (elemHasListener(element)) { element.removeEventListener('click', _this5[action]); @@ -355,10 +307,8 @@ var SidebarElement = /*#__PURE__*/function () { if (typeof value !== 'boolean') { throw new Error("You provided a ".concat(_typeof(value), " value but setSwipeGestures needs a boolean value.")); } - if (this.nativeSwipe) { value ? this.addNativeGestures() : this.removeNativeGestures(); - if (this.nativeSwipeOpen) { value ? this.addNativeOpenGestures() : this.removeNativeOpenGestures(); } @@ -394,7 +344,6 @@ var SidebarElement = /*#__PURE__*/function () { value: function removeComponentClassPosition(resetMainContent) { for (var i = 0; i < POSITIONS.length; i++) { this.removeComponentClass("".concat(SIDEBARJS, "--").concat(POSITIONS[i])); - if (resetMainContent && this.mainContent) { this.mainContent.classList.remove("".concat(SIDEBARJS_CONTENT, "--").concat(POSITIONS[i])); } @@ -403,16 +352,12 @@ var SidebarElement = /*#__PURE__*/function () { }, { key: "hasLeftPosition", value: function hasLeftPosition() { - return this.position === "left" - /* Left */ - ; + return this.position === "left" /* SidebarPosition.Left */; } }, { key: "hasRightPosition", value: function hasRightPosition() { - return this.position === "right" - /* Right */ - ; + return this.position === "right" /* SidebarPosition.Right */; } }, { key: "transcludeContent", @@ -420,11 +365,9 @@ var SidebarElement = /*#__PURE__*/function () { while (this.component.firstChild) { this.container.appendChild(this.component.firstChild); } - while (this.component.firstChild) { this.component.removeChild(this.component.firstChild); } - this.component.appendChild(this.container); this.component.appendChild(this.backdrop); } @@ -432,7 +375,6 @@ var SidebarElement = /*#__PURE__*/function () { key: "addNativeGestures", value: function addNativeGestures() { var _this6 = this; - this.nativeGestures.forEach(function (action, event) { _this6.component.addEventListener(event, action, EVENT_LISTENER_OPTIONS); }); @@ -441,7 +383,6 @@ var SidebarElement = /*#__PURE__*/function () { key: "removeNativeGestures", value: function removeNativeGestures() { var _this7 = this; - this.nativeGestures.forEach(function (action, event) { _this7.component.removeEventListener(event, action); }); @@ -485,11 +426,9 @@ var SidebarElement = /*#__PURE__*/function () { if (!this.responsive && this.mainContent) { throw new Error("You provide a [".concat(SIDEBARJS_CONTENT, "] element without set {responsive: true}")); } - if (this.responsive && !this.mainContent) { throw new Error("You have set {responsive: true} without provide a [".concat(SIDEBARJS_CONTENT, "] element")); } - this.addComponentClass('sidebarjs--responsive'); } }, { @@ -499,7 +438,6 @@ var SidebarElement = /*#__PURE__*/function () { el.attributeStyleMap.set(prop, val); } else { el.style[prop] = val; - if (vendorify) { var vendor = 'webkit' + prop.charAt(0).toUpperCase() + prop.slice(1); el.style[vendor] = val; @@ -531,17 +469,14 @@ var SidebarElement = /*#__PURE__*/function () { this.component.classList.toggle(className, force); } }]); - return SidebarElement; }(); var SidebarService = /*#__PURE__*/function () { function SidebarService() { _classCallCheck(this, SidebarService); - this.instances = {}; } - _createClass(SidebarService, [{ key: "fallbackName", value: function fallbackName(sidebarName) { @@ -556,7 +491,6 @@ var SidebarService = /*#__PURE__*/function () { key: "create", value: function create(options) { var _a; - var name = this.fallbackName((_a = options === null || options === void 0 ? void 0 : options.component) === null || _a === void 0 ? void 0 : _a.getAttribute(SIDEBARJS)); this.instances[name] = new SidebarElement(options); return this.instances[name]; @@ -565,35 +499,30 @@ var SidebarService = /*#__PURE__*/function () { key: "open", value: function open(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.open(); } }, { key: "close", value: function close(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.close(); } }, { key: "toggle", value: function toggle(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.toggle(); } }, { key: "isVisible", value: function isVisible(sidebarName) { var _a; - return !!((_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.isVisible()); } }, { key: "setPosition", value: function setPosition(position, sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.setPosition(position); } }, { @@ -605,7 +534,6 @@ var SidebarService = /*#__PURE__*/function () { key: "destroy", value: function destroy(sidebarName) { var name = this.fallbackName(sidebarName); - if (this.instances[name]) { this.instances[name].destroy(); this.instances[name] = null; @@ -613,7 +541,6 @@ var SidebarService = /*#__PURE__*/function () { } } }]); - return SidebarService; }(); diff --git a/lib/cjs/sidebarjs.min.js b/lib/cjs/sidebarjs.min.js index ca683f8..31158ed 100644 --- a/lib/cjs/sidebarjs.min.js +++ b/lib/cjs/sidebarjs.min.js @@ -1 +1 @@ -"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};e(this,n),this.toggle=function(){t.isVisible()?t.close():t.open()},this.open=function(){t.addComponentClass(s),t.setBackdropOpacity(t.backdropOpacity)},this.close=function(){t.removeComponentClass(s),t.clearStyle(t.backdrop)},this._onTouchStart=function(e){t.initialTouch=e.touches[0].pageX},this._onTouchMove=function(e){var n=-(t.initialTouch-e.touches[0].clientX);t.container.clientWidth+(t.hasLeftPosition()?n:-n)<=t.container.clientWidth&&(t.touchMoveSidebar=Math.abs(n),t.moveSidebar(n))},this._onTouchEnd=function(){t.removeComponentClass(a),t.clearStyle(t.container),t.clearStyle(t.backdrop),t.touchMoveSidebar>t.container.clientWidth/3.5?t.close():t.open(),t.initialTouch=null,t.touchMoveSidebar=null},this._onSwipeOpenStart=function(e){if(!f(e)){var n=e.touches[0].clientX;(t.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=t.documentMinSwipeX&&(t.openMovement=i?-s:s,t.moveSidebar(t.openMovement))}},this._onSwipeOpenEnd=function(){t.openMovement&&(t.openMovement=null,t._onTouchEnd())},this._onTransitionStart=function(){var e=t.getTransitionType(),n=e.open,i=e.close;(n||i)&&t.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var e=t.getTransitionType(),n=e.open,i=e.close,o=e.isVisible;(n||i)&&t.toggleTransitionClass(!1),n?(t._wasVisible=!0,y(t._emitOnOpen)):i&&(t._wasVisible=!1,y(t._emitOnClose)),t._emitOnChangeVisibility&&t._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([["touchstart",this._onTouchStart],["touchmove",this._onTouchMove],["touchend",this._onTouchEnd]]),this.nativeOpenGestures=new Map([["touchstart",this._onSwipeOpenStart],["touchmove",this._onSwipeOpenMove],["touchend",this._onSwipeOpenEnd]]);var r=Object.assign(Object.assign({},u),i),l=r.container&&r.backdrop;if(this.component=r.component||document.querySelector("[".concat(o,"]")),this.container=l?r.container:p("".concat(o,"-container")),this.backdrop=l?r.backdrop:p("".concat(o,"-backdrop")),this.documentMinSwipeX=r.documentMinSwipeX,this.documentSwipeRange=r.documentSwipeRange,this.nativeSwipe=!1!==r.nativeSwipe,this.nativeSwipeOpen=!1!==r.nativeSwipeOpen,this.isStyleMapSupported=h(),this.responsive=Boolean(r.responsive),this.mainContent=d(r.mainContent),this.backdropOpacity=r.backdropOpacity,this.backdropOpacityRatio=1/r.backdropOpacity,this._emitOnOpen=r.onOpen,this._emitOnClose=r.onClose,this._emitOnChangeVisibility=r.onChangeVisibility,!l)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(r.position),this.addAttrsEventsListeners(this.component.getAttribute(o)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,c)}return i(n,[{key:"isVisible",value:function(){return this.component.classList.contains(s)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(o)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(a),this.position=r.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(o,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(o,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat("sidebarjs-content","--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(a)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;m(t,(function(t,n){v(t)||(t.addEventListener("click",e[n],c),v(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;m(t,(function(t,n){v(t)&&(t.removeEventListener("click",e[n]),v(t,!1))}))}},{key:"setSwipeGestures",value:function(e){if("boolean"!=typeof e)throw new Error("You provided a ".concat(t(e)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(e?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(e?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,c),this.container.addEventListener("transitionend",this._onTransitionEnd,c)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};e(this,n),this.toggle=function(){t.isVisible()?t.close():t.open()},this.open=function(){t.addComponentClass(a),t.setBackdropOpacity(t.backdropOpacity)},this.close=function(){t.removeComponentClass(a),t.clearStyle(t.backdrop)},this._onTouchStart=function(e){t.initialTouch=e.touches[0].pageX},this._onTouchMove=function(e){var n=-(t.initialTouch-e.touches[0].clientX);t.container.clientWidth+(t.hasLeftPosition()?n:-n)<=t.container.clientWidth&&(t.touchMoveSidebar=Math.abs(n),t.moveSidebar(n))},this._onTouchEnd=function(){t.removeComponentClass(r),t.clearStyle(t.container),t.clearStyle(t.backdrop),t.touchMoveSidebar>t.container.clientWidth/3.5?t.close():t.open(),t.initialTouch=null,t.touchMoveSidebar=null},this._onSwipeOpenStart=function(e){if(!S(e)){var n=e.touches[0].clientX;(t.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=t.documentMinSwipeX&&(t.openMovement=i?-s:s,t.moveSidebar(t.openMovement))}},this._onSwipeOpenEnd=function(){t.openMovement&&(t.openMovement=null,t._onTouchEnd())},this._onTransitionStart=function(){var e=t.getTransitionType(),n=e.open,i=e.close;(n||i)&&t.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var e=t.getTransitionType(),n=e.open,i=e.close,o=e.isVisible;(n||i)&&t.toggleTransitionClass(!1),n?(t._wasVisible=!0,k(t._emitOnOpen)):i&&(t._wasVisible=!1,k(t._emitOnClose)),t._emitOnChangeVisibility&&t._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([[u,this._onTouchStart],[h,this._onTouchMove],[p,this._onTouchEnd]]),this.nativeOpenGestures=new Map([[u,this._onSwipeOpenStart],[h,this._onSwipeOpenMove],[p,this._onSwipeOpenEnd]]);var s=Object.assign(Object.assign({},d),i),c=s.container&&s.backdrop;if(this.component=s.component||document.querySelector("[".concat(o,"]")),this.container=c?s.container:f("".concat(o,"-container")),this.backdrop=c?s.backdrop:f("".concat(o,"-backdrop")),this.documentMinSwipeX=s.documentMinSwipeX,this.documentSwipeRange=s.documentSwipeRange,this.nativeSwipe=!1!==s.nativeSwipe,this.nativeSwipeOpen=!1!==s.nativeSwipeOpen,this.isStyleMapSupported=m(),this.responsive=Boolean(s.responsive),this.mainContent=b(s.mainContent),this.backdropOpacity=s.backdropOpacity,this.backdropOpacityRatio=1/s.backdropOpacity,this._emitOnOpen=s.onOpen,this._emitOnClose=s.onClose,this._emitOnChangeVisibility=s.onChangeVisibility,!c)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(s.position),this.addAttrsEventsListeners(this.component.getAttribute(o)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,l)}return i(n,[{key:"isVisible",value:function(){return this.component.classList.contains(a)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(o)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(r),this.position=c.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(o,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(o,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat(s,"--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(r)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;C(t,(function(t,n){y(t)||(t.addEventListener("click",e[n],l),y(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;C(t,(function(t,n){y(t)&&(t.removeEventListener("click",e[n]),y(t,!1))}))}},{key:"setSwipeGestures",value:function(e){if("boolean"!=typeof e)throw new Error("You provided a ".concat(t(e)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(e?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(e?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,l),this.container.addEventListener("transitionend",this._onTransitionEnd,l)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e= 0 ? position : "left" /* Left */; + this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* SidebarPosition.Left */; const resetMainContent = (document.querySelectorAll(`[${SIDEBARJS}]`) || []).length === 1; this.removeComponentClassPosition(resetMainContent); this.addComponentClass(`${SIDEBARJS}--${this.position}`); @@ -269,10 +269,10 @@ class SidebarElement { } } hasLeftPosition() { - return this.position === "left" /* Left */; + return this.position === "left" /* SidebarPosition.Left */; } hasRightPosition() { - return this.position === "right" /* Right */; + return this.position === "right" /* SidebarPosition.Right */; } transcludeContent() { while (this.component.firstChild) { diff --git a/lib/sidebarjs.css b/lib/sidebarjs.css index 4778417..8bf0b80 100644 --- a/lib/sidebarjs.css +++ b/lib/sidebarjs.css @@ -1,25 +1,30 @@ -[sidebarjs-backdrop], [sidebarjs] { +[sidebarjs], [sidebarjs-backdrop] { top: 0; left: 0; width: 100%; - height: 100%; } + height: 100%; +} -.sidebarjs--left[sidebarjs], [sidebarjs].sidebarjs--left [sidebarjs-container] { +[sidebarjs].sidebarjs--left [sidebarjs-container], [sidebarjs].sidebarjs--left { -webkit-transform: translate(-100%, 0); - transform: translate(-100%, 0); } + transform: translate(-100%, 0); +} -.sidebarjs--right[sidebarjs], [sidebarjs].sidebarjs--right [sidebarjs-container] { +[sidebarjs].sidebarjs--right [sidebarjs-container], [sidebarjs].sidebarjs--right { -webkit-transform: translate(100%, 0); - transform: translate(100%, 0); } + transform: translate(100%, 0); +} [sidebarjs].sidebarjs--left [sidebarjs-container] { -webkit-box-shadow: 2px 0 4px rgba(0, 0, 0, 0.2); - box-shadow: 2px 0 4px rgba(0, 0, 0, 0.2); } + box-shadow: 2px 0 4px rgba(0, 0, 0, 0.2); +} [sidebarjs].sidebarjs--right [sidebarjs-container] { -webkit-box-shadow: -2px 0 4px rgba(0, 0, 0, 0.2); box-shadow: -2px 0 4px rgba(0, 0, 0, 0.2); - margin-left: auto; } + margin-left: auto; +} [sidebarjs-backdrop] { position: absolute; @@ -27,7 +32,8 @@ opacity: 0; -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease; - will-change: opacity; } + will-change: opacity; +} [sidebarjs-container] { position: relative; @@ -47,7 +53,8 @@ transition: -webkit-transform ease 0.3s; transition: transform ease 0.3s; transition: transform ease 0.3s, -webkit-transform ease 0.3s; - will-change: transform; } + will-change: transform; +} [sidebarjs] { position: fixed; @@ -55,38 +62,46 @@ -webkit-transition: -webkit-transform 0s ease 0.3s; transition: -webkit-transform 0s ease 0.3s; transition: transform 0s ease 0.3s; - transition: transform 0s ease 0.3s, -webkit-transform 0s ease 0.3s; } - [sidebarjs].sidebarjs--is-visible { - -webkit-transform: translate(0, 0); - transform: translate(0, 0); - -webkit-transition: -webkit-transform 0s ease 0s; - transition: -webkit-transform 0s ease 0s; - transition: transform 0s ease 0s; - transition: transform 0s ease 0s, -webkit-transform 0s ease 0s; } - [sidebarjs].sidebarjs--is-visible [sidebarjs-container] { - -webkit-transform: translate(0, 0); - transform: translate(0, 0); } - [sidebarjs].sidebarjs--is-moving { - -webkit-transition: none; - transition: none; - -webkit-transform: translate(0, 0); - transform: translate(0, 0); } - [sidebarjs].sidebarjs--is-moving [sidebarjs-container], [sidebarjs].sidebarjs--is-moving [sidebarjs-backdrop] { - -webkit-transition: none; - transition: none; } + transition: transform 0s ease 0.3s, -webkit-transform 0s ease 0.3s; +} +[sidebarjs].sidebarjs--is-visible { + -webkit-transform: translate(0, 0); + transform: translate(0, 0); + -webkit-transition: -webkit-transform 0s ease 0s; + transition: -webkit-transform 0s ease 0s; + transition: transform 0s ease 0s; + transition: transform 0s ease 0s, -webkit-transform 0s ease 0s; +} +[sidebarjs].sidebarjs--is-visible [sidebarjs-container] { + -webkit-transform: translate(0, 0); + transform: translate(0, 0); +} +[sidebarjs].sidebarjs--is-moving { + -webkit-transition: none; + transition: none; + -webkit-transform: translate(0, 0); + transform: translate(0, 0); +} +[sidebarjs].sidebarjs--is-moving [sidebarjs-container], [sidebarjs].sidebarjs--is-moving [sidebarjs-backdrop] { + -webkit-transition: none; + transition: none; +} [sidebarjs-content] { position: relative; width: 100%; min-height: 100%; -webkit-transition: width 0.3s ease; - transition: width 0.3s ease; } - [sidebarjs-content].sidebarjs-content--left { - margin-left: auto; - margin-right: 0; } - [sidebarjs-content].sidebarjs-content--right { - margin-left: 0; - margin-right: auto; } + transition: width 0.3s ease; +} +[sidebarjs-content].sidebarjs-content--left { + margin-left: auto; + margin-right: 0; +} +[sidebarjs-content].sidebarjs-content--right { + margin-left: 0; + margin-right: auto; +} @media (min-width: 1025px) { [sidebarjs].sidebarjs--responsive { @@ -96,31 +111,41 @@ transition: -webkit-transform 0s ease 0s; transition: transform 0s ease 0s; transition: transform 0s ease 0s, -webkit-transform 0s ease 0s; - width: 300px; } - [sidebarjs].sidebarjs--responsive [sidebarjs-container] { - -webkit-transform: translate(0, 0) !important; - transform: translate(0, 0) !important; } - [sidebarjs].sidebarjs--responsive.sidebarjs--left { - left: 0; - right: auto; } - [sidebarjs].sidebarjs--responsive.sidebarjs--left [sidebarjs-container] { - -webkit-box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1); - box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1); } - [sidebarjs].sidebarjs--responsive.sidebarjs--right { - right: 0; - left: auto; } - [sidebarjs].sidebarjs--responsive.sidebarjs--right [sidebarjs-container] { - -webkit-box-shadow: -1px 0 0 rgba(0, 0, 0, 0.1); - box-shadow: -1px 0 0 rgba(0, 0, 0, 0.1); } - [sidebarjs].sidebarjs--responsive [sidebarjs-container] { - max-width: none; - width: 100%; - -webkit-box-shadow: none; - box-shadow: none; } + width: 300px; + } + [sidebarjs].sidebarjs--responsive [sidebarjs-container] { + -webkit-transform: translate(0, 0) !important; + transform: translate(0, 0) !important; + } + [sidebarjs].sidebarjs--responsive.sidebarjs--left { + left: 0; + right: auto; + } + [sidebarjs].sidebarjs--responsive.sidebarjs--left [sidebarjs-container] { + -webkit-box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1); + box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1); + } + [sidebarjs].sidebarjs--responsive.sidebarjs--right { + right: 0; + left: auto; + } + [sidebarjs].sidebarjs--responsive.sidebarjs--right [sidebarjs-container] { + -webkit-box-shadow: -1px 0 0 rgba(0, 0, 0, 0.1); + box-shadow: -1px 0 0 rgba(0, 0, 0, 0.1); + } + [sidebarjs].sidebarjs--responsive [sidebarjs-container] { + max-width: none; + width: 100%; + -webkit-box-shadow: none; + box-shadow: none; + } [sidebarjs-content] { width: -webkit-calc(100% - 300px); - width: calc(100% - 300px); } - [sidebarjs-content].sidebarjs-content--left.sidebarjs-content--right { - width: -webkit-calc(100% - 600px); - width: calc(100% - 600px); - margin: 0 auto; } } + width: calc(100% - 300px); + } + [sidebarjs-content].sidebarjs-content--left.sidebarjs-content--right { + width: -webkit-calc(100% - 600px); + width: calc(100% - 600px); + margin: 0 auto; + } +} diff --git a/lib/sidebarjs.min.css b/lib/sidebarjs.min.css index e834f37..f317a1c 100644 --- a/lib/sidebarjs.min.css +++ b/lib/sidebarjs.min.css @@ -1 +1 @@ -[sidebarjs-backdrop],[sidebarjs]{height:100%;left:0;top:0;width:100%}.sidebarjs--left[sidebarjs],[sidebarjs].sidebarjs--left [sidebarjs-container]{-webkit-transform:translate(-100%);transform:translate(-100%)}.sidebarjs--right[sidebarjs],[sidebarjs].sidebarjs--right [sidebarjs-container]{-webkit-transform:translate(100%);transform:translate(100%)}[sidebarjs].sidebarjs--left [sidebarjs-container]{-webkit-box-shadow:2px 0 4px rgba(0,0,0,.2);box-shadow:2px 0 4px rgba(0,0,0,.2)}[sidebarjs].sidebarjs--right [sidebarjs-container]{-webkit-box-shadow:-2px 0 4px rgba(0,0,0,.2);box-shadow:-2px 0 4px rgba(0,0,0,.2);margin-left:auto}[sidebarjs-backdrop]{background:#000;opacity:0;position:absolute;-webkit-transition:opacity .3s ease;transition:opacity .3s ease;will-change:opacity}[sidebarjs-container]{-webkit-box-orient:vertical;-webkit-box-direction:normal;background:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;height:100%;max-width:300px;position:relative;-webkit-transition:-webkit-transform .3s ease;transition:-webkit-transform .3s ease;transition:transform .3s ease;transition:transform .3s ease,-webkit-transform .3s ease;width:90%;will-change:transform;z-index:1}[sidebarjs]{position:fixed;-webkit-transition:-webkit-transform 0s ease .3s;transition:-webkit-transform 0s ease .3s;transition:transform 0s ease .3s;transition:transform 0s ease .3s,-webkit-transform 0s ease .3s;z-index:9999}[sidebarjs].sidebarjs--is-visible{-webkit-transition:-webkit-transform 0s ease 0s;transition:-webkit-transform 0s ease 0s;transition:transform 0s ease 0s;transition:transform 0s ease 0s,-webkit-transform 0s ease 0s}[sidebarjs].sidebarjs--is-moving,[sidebarjs].sidebarjs--is-visible,[sidebarjs].sidebarjs--is-visible [sidebarjs-container]{-webkit-transform:translate(0);transform:translate(0)}[sidebarjs].sidebarjs--is-moving,[sidebarjs].sidebarjs--is-moving [sidebarjs-backdrop],[sidebarjs].sidebarjs--is-moving [sidebarjs-container]{-webkit-transition:none;transition:none}[sidebarjs-content]{min-height:100%;position:relative;-webkit-transition:width .3s ease;transition:width .3s ease;width:100%}[sidebarjs-content].sidebarjs-content--left{margin-left:auto;margin-right:0}[sidebarjs-content].sidebarjs-content--right{margin-left:0;margin-right:auto}@media (min-width:1025px){[sidebarjs].sidebarjs--responsive{-webkit-transition:-webkit-transform 0s ease 0s;transition:-webkit-transform 0s ease 0s;transition:transform 0s ease 0s;transition:transform 0s ease 0s,-webkit-transform 0s ease 0s;width:300px}[sidebarjs].sidebarjs--responsive,[sidebarjs].sidebarjs--responsive [sidebarjs-container]{-webkit-transform:translate(0)!important;transform:translate(0)!important}[sidebarjs].sidebarjs--responsive.sidebarjs--left{left:0;right:auto}[sidebarjs].sidebarjs--responsive.sidebarjs--left [sidebarjs-container]{-webkit-box-shadow:1px 0 0 rgba(0,0,0,.1);box-shadow:1px 0 0 rgba(0,0,0,.1)}[sidebarjs].sidebarjs--responsive.sidebarjs--right{left:auto;right:0}[sidebarjs].sidebarjs--responsive.sidebarjs--right [sidebarjs-container]{-webkit-box-shadow:-1px 0 0 rgba(0,0,0,.1);box-shadow:-1px 0 0 rgba(0,0,0,.1)}[sidebarjs].sidebarjs--responsive [sidebarjs-container]{-webkit-box-shadow:none;box-shadow:none;max-width:none;width:100%}[sidebarjs-content]{width:-webkit-calc(100% - 300px);width:calc(100% - 300px)}[sidebarjs-content].sidebarjs-content--left.sidebarjs-content--right{margin:0 auto;width:-webkit-calc(100% - 600px);width:calc(100% - 600px)}} \ No newline at end of file +[sidebarjs-backdrop],[sidebarjs]{height:100%;left:0;top:0;width:100%}[sidebarjs].sidebarjs--left,[sidebarjs].sidebarjs--left [sidebarjs-container]{-webkit-transform:translate(-100%);transform:translate(-100%)}[sidebarjs].sidebarjs--right,[sidebarjs].sidebarjs--right [sidebarjs-container]{-webkit-transform:translate(100%);transform:translate(100%)}[sidebarjs].sidebarjs--left [sidebarjs-container]{-webkit-box-shadow:2px 0 4px rgba(0,0,0,.2);box-shadow:2px 0 4px rgba(0,0,0,.2)}[sidebarjs].sidebarjs--right [sidebarjs-container]{-webkit-box-shadow:-2px 0 4px rgba(0,0,0,.2);box-shadow:-2px 0 4px rgba(0,0,0,.2);margin-left:auto}[sidebarjs-backdrop]{background:#000;opacity:0;position:absolute;-webkit-transition:opacity .3s ease;transition:opacity .3s ease;will-change:opacity}[sidebarjs-container]{-webkit-box-orient:vertical;-webkit-box-direction:normal;background:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;height:100%;max-width:300px;position:relative;-webkit-transition:-webkit-transform .3s ease;transition:-webkit-transform .3s ease;transition:transform .3s ease;transition:transform .3s ease,-webkit-transform .3s ease;width:90%;will-change:transform;z-index:1}[sidebarjs]{position:fixed;-webkit-transition:-webkit-transform 0s ease .3s;transition:-webkit-transform 0s ease .3s;transition:transform 0s ease .3s;transition:transform 0s ease .3s,-webkit-transform 0s ease .3s;z-index:9999}[sidebarjs].sidebarjs--is-visible{-webkit-transition:-webkit-transform 0s ease 0s;transition:-webkit-transform 0s ease 0s;transition:transform 0s ease 0s;transition:transform 0s ease 0s,-webkit-transform 0s ease 0s}[sidebarjs].sidebarjs--is-moving,[sidebarjs].sidebarjs--is-visible,[sidebarjs].sidebarjs--is-visible [sidebarjs-container]{-webkit-transform:translate(0);transform:translate(0)}[sidebarjs].sidebarjs--is-moving,[sidebarjs].sidebarjs--is-moving [sidebarjs-backdrop],[sidebarjs].sidebarjs--is-moving [sidebarjs-container]{-webkit-transition:none;transition:none}[sidebarjs-content]{min-height:100%;position:relative;-webkit-transition:width .3s ease;transition:width .3s ease;width:100%}[sidebarjs-content].sidebarjs-content--left{margin-left:auto;margin-right:0}[sidebarjs-content].sidebarjs-content--right{margin-left:0;margin-right:auto}@media (min-width:1025px){[sidebarjs].sidebarjs--responsive{-webkit-transition:-webkit-transform 0s ease 0s;transition:-webkit-transform 0s ease 0s;transition:transform 0s ease 0s;transition:transform 0s ease 0s,-webkit-transform 0s ease 0s;width:300px}[sidebarjs].sidebarjs--responsive,[sidebarjs].sidebarjs--responsive [sidebarjs-container]{-webkit-transform:translate(0)!important;transform:translate(0)!important}[sidebarjs].sidebarjs--responsive.sidebarjs--left{left:0;right:auto}[sidebarjs].sidebarjs--responsive.sidebarjs--left [sidebarjs-container]{-webkit-box-shadow:1px 0 0 rgba(0,0,0,.1);box-shadow:1px 0 0 rgba(0,0,0,.1)}[sidebarjs].sidebarjs--responsive.sidebarjs--right{left:auto;right:0}[sidebarjs].sidebarjs--responsive.sidebarjs--right [sidebarjs-container]{-webkit-box-shadow:-1px 0 0 rgba(0,0,0,.1);box-shadow:-1px 0 0 rgba(0,0,0,.1)}[sidebarjs].sidebarjs--responsive [sidebarjs-container]{-webkit-box-shadow:none;box-shadow:none;max-width:none;width:100%}[sidebarjs-content]{width:-webkit-calc(100% - 300px);width:calc(100% - 300px)}[sidebarjs-content].sidebarjs-content--left.sidebarjs-content--right{margin:0 auto;width:-webkit-calc(100% - 600px);width:calc(100% - 600px)}} \ No newline at end of file diff --git a/lib/src/sidebar.core.d.ts b/lib/src/sidebar.core.d.ts index 3d5b749..fc46e83 100644 --- a/lib/src/sidebar.core.d.ts +++ b/lib/src/sidebar.core.d.ts @@ -18,7 +18,7 @@ declare const ELEMENT_ACTIONS: readonly ["toggle", "open", "close"]; export interface SidebarChangeEvent { isVisible: boolean; } -export declare type MapGestureEvent = Map; +export type MapGestureEvent = Map; export declare const DEFAULT_CONFIG: SidebarConfig; export interface SidebarBase { open: () => void; diff --git a/lib/src/sidebar.core.js b/lib/src/sidebar.core.js index f6bf6b8..40fc92c 100644 --- a/lib/src/sidebar.core.js +++ b/lib/src/sidebar.core.js @@ -5,7 +5,7 @@ export const SIDEBARJS_TRANSITION_START = 'sidebarjs--transition-start'; export const SIDEBARJS_TRANSITION_END = 'sidebarjs--transition-end'; export const IS_VISIBLE = `${SIDEBARJS}--is-visible`; export const IS_MOVING = `${SIDEBARJS}--is-moving`; -export const POSITIONS = ["left" /* Left */, "right" /* Right */]; +export const POSITIONS = ["left" /* SidebarPosition.Left */, "right" /* SidebarPosition.Right */]; export const EVENT_LISTENER_OPTIONS = { passive: true }; export const TOUCH_START = 'touchstart'; export const TOUCH_MOVE = 'touchmove'; @@ -15,7 +15,7 @@ export const DEFAULT_CONFIG = { documentMinSwipeX: 10, documentSwipeRange: 40, responsive: false, - position: "left" /* Left */, + position: "left" /* SidebarPosition.Left */, backdropOpacity: 0.3, }; export function isStyleMapSupported() { diff --git a/lib/src/sidebar.core.js.map b/lib/src/sidebar.core.js.map index 20f368c..d3c959a 100644 --- a/lib/src/sidebar.core.js.map +++ b/lib/src/sidebar.core.js.map @@ -1 +1 @@ -{"version":3,"file":"sidebar.core.js","sourceRoot":"","sources":["../../src/sidebar.core.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AACxE,MAAM,CAAC,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,SAAS,cAAc,CAAC;AACrD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,SAAS,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,SAAS,GAAsB,wCAA6C,CAAC;AAC1F,MAAM,CAAC,MAAM,sBAAsB,GAA4B,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;AAO/E,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAEpC,MAAM,e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AE,CAAC,EAAE,EAAE;QAC/C,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC,IAAI,SAAS,IAAI,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC;QACxF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAgB,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,CAAa;IACnD,OAAQ,CAAC,CAAC,MAAsB,CAAC,YAAY,CAAC,GAAG,SAAS,WAAW,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAqB;IACxD,IAAI,EAAE,EAAE;QACN,EAAE,EAAE,CAAC;KACN;AACH,CAAC"} \ No newline at end of file diff --git a/lib/src/sidebar.element.js b/lib/src/sidebar.element.js index 69fb52e..c1599d9 100644 --- a/lib/src/sidebar.element.js +++ b/lib/src/sidebar.element.js @@ -146,7 +146,7 @@ export class SidebarElement { } setPosition(position) { this.addComponentClass(IS_MOVING); - this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* Left */; + this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* SidebarPosition.Left */; const resetMainContent = (document.querySelectorAll(`[${SIDEBARJS}]`) || []).length === 1; this.removeComponentClassPosition(resetMainContent); this.addComponentClass(`${SIDEBARJS}--${this.position}`); @@ -206,10 +206,10 @@ export class SidebarElement { } } hasLeftPosition() { - return this.position === "left" /* Left */; + return this.position === "left" /* SidebarPosition.Left */; } hasRightPosition() { - return this.position === "right" /* Right */; + return this.position === "right" /* SidebarPosition.Right */; } transcludeContent() { while (this.component.firstChild) { diff --git a/lib/src/sidebar.element.js.map b/lib/src/sidebar.element.js.map index ee56ef2..f51f7dc 100644 --- a/lib/src/sidebar.element.js.map +++ b/lib/src/sidebar.element.js.map @@ -1 +1 @@ -{"version":3,"file":"sidebar.element.js","sourceRoot":"","sources":["../../src/sidebar.element.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,mBAAmB,EAEnB,SAAS,EACT,uBAAuB,EACvB,oBAAoB,EAIpB,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAE1B,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAQxB,MAAM,OAAO,cAAc;IAsBzB,YAAY,UAAyB,EAAE;QAuChC,WAAM,GAAG,GAAS,EAAE;YACzB,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChD,CAAC,CAAC;QAEK,SAAI,GAAG,GAAS,EAAE;YACvB,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAChD,CAAC,CAAC;QAEK,UAAK,GAAG,GAAS,EAAE;YACxB,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC;QAgEM,kBAAa,GAAG,CAAC,CAAa,EAAQ,EAAE;YAC9C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACzC,CAAC,CAAC;QAEM,iBAAY,GAAG,CAAC,CAAa,EAAQ,EAAE;YAC7C,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,YAAa,GAAG,CAAC,CAAC,OAAO,CAAC,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C,CAAC,CAAC,CAAuB,CAAC;gBAC/F,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;aACxB;SACF;IACH,CAAC;IAEO,UAAU,CAAC,EAAe;QAChC,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC3B,EAAU,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;SACvC;aAAM;YACL,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SAC7B;IACH,CAAC;IAEO,iBAAiB,CAAC,SAAiB;QACzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAEO,oBAAoB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAEO,oBAAoB,CAAC,SAAiB,EAAE,KAAe;QAC7D,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"sidebar.element.js","sourceRoot":"","sources":["../../src/sidebar.element.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,mBAAmB,EAEnB,SAAS,EACT,uBAAuB,EACvB,oBAAoB,EAIpB,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAE1B,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAQxB,MAAM,OAAO,cAAc;IAsBzB,YAAY,UAAyB,EAAE;QAuChC,WAAM,GAAG,GAAS,EAAE;YACzB,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAA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S,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;CACF"} \ No newline at end of file diff --git a/lib/umd/sidebarjs.js b/lib/umd/sidebarjs.js index 4f849fd..0150cbc 100644 --- a/lib/umd/sidebarjs.js +++ b/lib/umd/sidebarjs.js @@ -1,6 +1,6 @@ /* * SidebarJS - * Version 9.0.0 + * Version 10.0.0 * https://github.com/SidebarJS/sidebarjs#readme */ @@ -8,45 +8,53 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SidebarJS = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; function _typeof(obj) { "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); return Constructor; } + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); + } + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); + } var SIDEBARJS = 'sidebarjs'; var SIDEBARJS_FALLBACK_NAME = ''; @@ -55,11 +63,7 @@ var SIDEBARJS_TRANSITION_END = 'sidebarjs--transition-end'; var IS_VISIBLE = "".concat(SIDEBARJS, "--is-visible"); var IS_MOVING = "".concat(SIDEBARJS, "--is-moving"); - var POSITIONS = ["left" - /* Left */ - , "right" - /* Right */ - ]; + var POSITIONS = ["left" /* SidebarPosition.Left */, "right" /* SidebarPosition.Right */]; var EVENT_LISTENER_OPTIONS = { passive: true }; @@ -71,9 +75,7 @@ documentMinSwipeX: 10, documentSwipeRange: 40, responsive: false, - position: "left" - /* Left */ - , + position: "left" /* SidebarPosition.Left */, backdropOpacity: 0.3 }; function isStyleMapSupported() { @@ -99,7 +101,6 @@ for (var i = 0; i < ELEMENT_ACTIONS.length; i++) { var action = ELEMENT_ACTIONS[i]; var elements = document.querySelectorAll("[".concat(SIDEBARJS, "-").concat(action, "=\"").concat(sidebarName, "\"]")); - for (var j = 0; j < elements.length; j++) { func(elements[j], action); } @@ -117,112 +118,82 @@ var SidebarElement = /*#__PURE__*/function () { function SidebarElement() { var _this = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - _classCallCheck(this, SidebarElement); - this.toggle = function () { _this.isVisible() ? _this.close() : _this.open(); }; - this.open = function () { _this.addComponentClass(IS_VISIBLE); - _this.setBackdropOpacity(_this.backdropOpacity); }; - this.close = function () { _this.removeComponentClass(IS_VISIBLE); - _this.clearStyle(_this.backdrop); }; - this._onTouchStart = function (e) { _this.initialTouch = e.touches[0].pageX; }; - this._onTouchMove = function (e) { var swipeDirection = -(_this.initialTouch - e.touches[0].clientX); var sidebarMovement = _this.container.clientWidth + (_this.hasLeftPosition() ? swipeDirection : -swipeDirection); - if (sidebarMovement <= _this.container.clientWidth) { _this.touchMoveSidebar = Math.abs(swipeDirection); - _this.moveSidebar(swipeDirection); } }; - this._onTouchEnd = function () { _this.removeComponentClass(IS_MOVING); - _this.clearStyle(_this.container); - _this.clearStyle(_this.backdrop); - _this.touchMoveSidebar > _this.container.clientWidth / 3.5 ? _this.close() : _this.open(); _this.initialTouch = null; _this.touchMoveSidebar = null; }; - this._onSwipeOpenStart = function (e) { if (targetElementIsBackdrop(e)) { return; } - var touchPositionX = e.touches[0].clientX; var documentTouch = _this.hasLeftPosition() ? touchPositionX : document.body.clientWidth - touchPositionX; - if (documentTouch < _this.documentSwipeRange) { _this._onTouchStart(e); } }; - this._onSwipeOpenMove = function (e) { if (!targetElementIsBackdrop(e) && _this.initialTouch && !_this.isVisible()) { var documentSwiped = e.touches[0].clientX - _this.initialTouch; - var hasLeftPosition = _this.hasLeftPosition(); - var swipeX = hasLeftPosition ? documentSwiped : -documentSwiped; var sidebarMovement = _this.container.clientWidth - swipeX; - if (sidebarMovement > 0 && swipeX >= _this.documentMinSwipeX) { _this.openMovement = hasLeftPosition ? -sidebarMovement : sidebarMovement; - _this.moveSidebar(_this.openMovement); } } }; - this._onSwipeOpenEnd = function () { if (_this.openMovement) { _this.openMovement = null; - _this._onTouchEnd(); } }; - this._onTransitionStart = function () { var _this$getTransitionTy = _this.getTransitionType(), - open = _this$getTransitionTy.open, - close = _this$getTransitionTy.close; - + open = _this$getTransitionTy.open, + close = _this$getTransitionTy.close; if (open || close) { _this.toggleTransitionClass(true); } }; - this._onTransitionEnd = function () { var _this$getTransitionTy2 = _this.getTransitionType(), - open = _this$getTransitionTy2.open, - close = _this$getTransitionTy2.close, - isVisible = _this$getTransitionTy2.isVisible; - + open = _this$getTransitionTy2.open, + close = _this$getTransitionTy2.close, + isVisible = _this$getTransitionTy2.isVisible; if (open || close) { _this.toggleTransitionClass(false); } - if (open) { _this._wasVisible = true; shouldInvokeFunction(_this._emitOnOpen); @@ -230,14 +201,12 @@ _this._wasVisible = false; shouldInvokeFunction(_this._emitOnClose); } - if (_this._emitOnChangeVisibility) { _this._emitOnChangeVisibility({ isVisible: isVisible }); } }; - this.nativeGestures = new Map([[TOUCH_START, this._onTouchStart], [TOUCH_MOVE, this._onTouchMove], [TOUCH_END, this._onTouchEnd]]); this.nativeOpenGestures = new Map([[TOUCH_START, this._onSwipeOpenStart], [TOUCH_MOVE, this._onSwipeOpenMove], [TOUCH_END, this._onSwipeOpenEnd]]); var config = Object.assign(Object.assign({}, DEFAULT_CONFIG), options); @@ -257,7 +226,6 @@ this._emitOnOpen = config.onOpen; this._emitOnClose = config.onClose; this._emitOnChangeVisibility = config.onChangeVisibility; - if (!hasCustomTransclude) { try { this.transcludeContent(); @@ -265,19 +233,15 @@ throw new Error('You must define an element with [sidebarjs] attribute'); } } - this.setSwipeGestures(true); - if (this.responsive || this.mainContent) { this.setResponsive(); } - this.setPosition(config.position); this.addAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.addTransitionListener(); this.backdrop.addEventListener('click', this.close, EVENT_LISTENER_OPTIONS); } - _createClass(SidebarElement, [{ key: "isVisible", value: function isVisible() { @@ -287,7 +251,6 @@ key: "destroy", value: function destroy() { var _this2 = this; - this.removeNativeGestures(); this.container.removeEventListener('transitionstart', this._onTransitionStart); this.container.removeEventListener('transitionend', this._onTransitionEnd); @@ -295,11 +258,9 @@ this.removeNativeOpenGestures(); this.removeAttrsEventsListeners(this.component.getAttribute(SIDEBARJS)); this.removeComponentClassPosition(); - while (this.container.firstElementChild) { this.component.appendChild(this.container.firstElementChild); } - this.component.removeChild(this.container); this.component.removeChild(this.backdrop); Object.keys(this).forEach(function (key) { @@ -310,19 +271,14 @@ key: "setPosition", value: function setPosition(position) { var _this3 = this; - this.addComponentClass(IS_MOVING); - this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" - /* Left */ - ; + this.position = POSITIONS.indexOf(position) >= 0 ? position : "left" /* SidebarPosition.Left */; var resetMainContent = (document.querySelectorAll("[".concat(SIDEBARJS, "]")) || []).length === 1; this.removeComponentClassPosition(resetMainContent); this.addComponentClass("".concat(SIDEBARJS, "--").concat(this.position)); - if (this.responsive && this.mainContent) { this.mainContent.classList.add("".concat(SIDEBARJS_CONTENT, "--").concat(this.position)); } - setTimeout(function () { return _this3.component && _this3.removeComponentClass(IS_MOVING); }, 200); @@ -331,7 +287,6 @@ key: "addAttrsEventsListeners", value: function addAttrsEventsListeners(sidebarName) { var _this4 = this; - forEachActionElement(sidebarName, function (element, action) { if (!elemHasListener(element)) { element.addEventListener('click', _this4[action], EVENT_LISTENER_OPTIONS); @@ -343,7 +298,6 @@ key: "removeAttrsEventsListeners", value: function removeAttrsEventsListeners(sidebarName) { var _this5 = this; - forEachActionElement(sidebarName, function (element, action) { if (elemHasListener(element)) { element.removeEventListener('click', _this5[action]); @@ -357,10 +311,8 @@ if (typeof value !== 'boolean') { throw new Error("You provided a ".concat(_typeof(value), " value but setSwipeGestures needs a boolean value.")); } - if (this.nativeSwipe) { value ? this.addNativeGestures() : this.removeNativeGestures(); - if (this.nativeSwipeOpen) { value ? this.addNativeOpenGestures() : this.removeNativeOpenGestures(); } @@ -396,7 +348,6 @@ value: function removeComponentClassPosition(resetMainContent) { for (var i = 0; i < POSITIONS.length; i++) { this.removeComponentClass("".concat(SIDEBARJS, "--").concat(POSITIONS[i])); - if (resetMainContent && this.mainContent) { this.mainContent.classList.remove("".concat(SIDEBARJS_CONTENT, "--").concat(POSITIONS[i])); } @@ -405,16 +356,12 @@ }, { key: "hasLeftPosition", value: function hasLeftPosition() { - return this.position === "left" - /* Left */ - ; + return this.position === "left" /* SidebarPosition.Left */; } }, { key: "hasRightPosition", value: function hasRightPosition() { - return this.position === "right" - /* Right */ - ; + return this.position === "right" /* SidebarPosition.Right */; } }, { key: "transcludeContent", @@ -422,11 +369,9 @@ while (this.component.firstChild) { this.container.appendChild(this.component.firstChild); } - while (this.component.firstChild) { this.component.removeChild(this.component.firstChild); } - this.component.appendChild(this.container); this.component.appendChild(this.backdrop); } @@ -434,7 +379,6 @@ key: "addNativeGestures", value: function addNativeGestures() { var _this6 = this; - this.nativeGestures.forEach(function (action, event) { _this6.component.addEventListener(event, action, EVENT_LISTENER_OPTIONS); }); @@ -443,7 +387,6 @@ key: "removeNativeGestures", value: function removeNativeGestures() { var _this7 = this; - this.nativeGestures.forEach(function (action, event) { _this7.component.removeEventListener(event, action); }); @@ -487,11 +430,9 @@ if (!this.responsive && this.mainContent) { throw new Error("You provide a [".concat(SIDEBARJS_CONTENT, "] element without set {responsive: true}")); } - if (this.responsive && !this.mainContent) { throw new Error("You have set {responsive: true} without provide a [".concat(SIDEBARJS_CONTENT, "] element")); } - this.addComponentClass('sidebarjs--responsive'); } }, { @@ -501,7 +442,6 @@ el.attributeStyleMap.set(prop, val); } else { el.style[prop] = val; - if (vendorify) { var vendor = 'webkit' + prop.charAt(0).toUpperCase() + prop.slice(1); el.style[vendor] = val; @@ -533,17 +473,14 @@ this.component.classList.toggle(className, force); } }]); - return SidebarElement; }(); var SidebarService = /*#__PURE__*/function () { function SidebarService() { _classCallCheck(this, SidebarService); - this.instances = {}; } - _createClass(SidebarService, [{ key: "fallbackName", value: function fallbackName(sidebarName) { @@ -558,7 +495,6 @@ key: "create", value: function create(options) { var _a; - var name = this.fallbackName((_a = options === null || options === void 0 ? void 0 : options.component) === null || _a === void 0 ? void 0 : _a.getAttribute(SIDEBARJS)); this.instances[name] = new SidebarElement(options); return this.instances[name]; @@ -567,35 +503,30 @@ key: "open", value: function open(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.open(); } }, { key: "close", value: function close(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.close(); } }, { key: "toggle", value: function toggle(sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.toggle(); } }, { key: "isVisible", value: function isVisible(sidebarName) { var _a; - return !!((_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.isVisible()); } }, { key: "setPosition", value: function setPosition(position, sidebarName) { var _a; - (_a = this.getInstance(sidebarName)) === null || _a === void 0 ? void 0 : _a.setPosition(position); } }, { @@ -607,7 +538,6 @@ key: "destroy", value: function destroy(sidebarName) { var name = this.fallbackName(sidebarName); - if (this.instances[name]) { this.instances[name].destroy(); this.instances[name] = null; @@ -615,13 +545,10 @@ } } }]); - return SidebarService; }(); exports.SidebarElement = SidebarElement; exports.SidebarService = SidebarService; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/lib/umd/sidebarjs.min.js b/lib/umd/sidebarjs.min.js index 31c79f4..2bcb63a 100644 --- a/lib/umd/sidebarjs.min.js +++ b/lib/umd/sidebarjs.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SidebarJS={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),this.toggle=function(){e.isVisible()?e.close():e.open()},this.open=function(){e.addComponentClass(r),e.setBackdropOpacity(e.backdropOpacity)},this.close=function(){e.removeComponentClass(r),e.clearStyle(e.backdrop)},this._onTouchStart=function(t){e.initialTouch=t.touches[0].pageX},this._onTouchMove=function(t){var n=-(e.initialTouch-t.touches[0].clientX);e.container.clientWidth+(e.hasLeftPosition()?n:-n)<=e.container.clientWidth&&(e.touchMoveSidebar=Math.abs(n),e.moveSidebar(n))},this._onTouchEnd=function(){e.removeComponentClass(c),e.clearStyle(e.container),e.clearStyle(e.backdrop),e.touchMoveSidebar>e.container.clientWidth/3.5?e.close():e.open(),e.initialTouch=null,e.touchMoveSidebar=null},this._onSwipeOpenStart=function(t){if(!S(t)){var n=t.touches[0].clientX;(e.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=e.documentMinSwipeX&&(e.openMovement=i?-s:s,e.moveSidebar(e.openMovement))}},this._onSwipeOpenEnd=function(){e.openMovement&&(e.openMovement=null,e._onTouchEnd())},this._onTransitionStart=function(){var t=e.getTransitionType(),n=t.open,i=t.close;(n||i)&&e.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var t=e.getTransitionType(),n=t.open,i=t.close,o=t.isVisible;(n||i)&&e.toggleTransitionClass(!1),n?(e._wasVisible=!0,g(e._emitOnOpen)):i&&(e._wasVisible=!1,g(e._emitOnClose)),e._emitOnChangeVisibility&&e._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([[h,this._onTouchStart],[p,this._onTouchMove],[v,this._onTouchEnd]]),this.nativeOpenGestures=new Map([[h,this._onSwipeOpenStart],[p,this._onSwipeOpenMove],[v,this._onSwipeOpenEnd]]);var o=Object.assign(Object.assign({},f),i),a=o.container&&o.backdrop;if(this.component=o.component||document.querySelector("[".concat(s,"]")),this.container=a?o.container:y("".concat(s,"-container")),this.backdrop=a?o.backdrop:y("".concat(s,"-backdrop")),this.documentMinSwipeX=o.documentMinSwipeX,this.documentSwipeRange=o.documentSwipeRange,this.nativeSwipe=!1!==o.nativeSwipe,this.nativeSwipeOpen=!1!==o.nativeSwipeOpen,this.isStyleMapSupported=m(),this.responsive=Boolean(o.responsive),this.mainContent=C(o.mainContent),this.backdropOpacity=o.backdropOpacity,this.backdropOpacityRatio=1/o.backdropOpacity,this._emitOnOpen=o.onOpen,this._emitOnClose=o.onClose,this._emitOnChangeVisibility=o.onChangeVisibility,!a)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(o.position),this.addAttrsEventsListeners(this.component.getAttribute(s)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,u)}return o(t,[{key:"isVisible",value:function(){return this.component.classList.contains(r)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(s)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(c),this.position=l.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(s,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(s,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat(a,"--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(c)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;k(t,(function(t,n){b(t)||(t.addEventListener("click",e[n],u),b(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;k(t,(function(t,n){b(t)&&(t.removeEventListener("click",e[n]),b(t,!1))}))}},{key:"setSwipeGestures",value:function(t){if("boolean"!=typeof t)throw new Error("You provided a ".concat(e(t)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(t?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(t?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,u),this.container.addEventListener("transitionend",this._onTransitionEnd,u)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),this.toggle=function(){e.isVisible()?e.close():e.open()},this.open=function(){e.addComponentClass(r),e.setBackdropOpacity(e.backdropOpacity)},this.close=function(){e.removeComponentClass(r),e.clearStyle(e.backdrop)},this._onTouchStart=function(t){e.initialTouch=t.touches[0].pageX},this._onTouchMove=function(t){var n=-(e.initialTouch-t.touches[0].clientX);e.container.clientWidth+(e.hasLeftPosition()?n:-n)<=e.container.clientWidth&&(e.touchMoveSidebar=Math.abs(n),e.moveSidebar(n))},this._onTouchEnd=function(){e.removeComponentClass(c),e.clearStyle(e.container),e.clearStyle(e.backdrop),e.touchMoveSidebar>e.container.clientWidth/3.5?e.close():e.open(),e.initialTouch=null,e.touchMoveSidebar=null},this._onSwipeOpenStart=function(t){if(!k(t)){var n=t.touches[0].clientX;(e.hasLeftPosition()?n:document.body.clientWidth-n)0&&o>=e.documentMinSwipeX&&(e.openMovement=i?-s:s,e.moveSidebar(e.openMovement))}},this._onSwipeOpenEnd=function(){e.openMovement&&(e.openMovement=null,e._onTouchEnd())},this._onTransitionStart=function(){var t=e.getTransitionType(),n=t.open,i=t.close;(n||i)&&e.toggleTransitionClass(!0)},this._onTransitionEnd=function(){var t=e.getTransitionType(),n=t.open,i=t.close,o=t.isVisible;(n||i)&&e.toggleTransitionClass(!1),n?(e._wasVisible=!0,g(e._emitOnOpen)):i&&(e._wasVisible=!1,g(e._emitOnClose)),e._emitOnChangeVisibility&&e._emitOnChangeVisibility({isVisible:o})},this.nativeGestures=new Map([[h,this._onTouchStart],[p,this._onTouchMove],[v,this._onTouchEnd]]),this.nativeOpenGestures=new Map([[h,this._onSwipeOpenStart],[p,this._onSwipeOpenMove],[v,this._onSwipeOpenEnd]]);var o=Object.assign(Object.assign({},f),i),a=o.container&&o.backdrop;if(this.component=o.component||document.querySelector("[".concat(s,"]")),this.container=a?o.container:y("".concat(s,"-container")),this.backdrop=a?o.backdrop:y("".concat(s,"-backdrop")),this.documentMinSwipeX=o.documentMinSwipeX,this.documentSwipeRange=o.documentSwipeRange,this.nativeSwipe=!1!==o.nativeSwipe,this.nativeSwipeOpen=!1!==o.nativeSwipeOpen,this.isStyleMapSupported=m(),this.responsive=Boolean(o.responsive),this.mainContent=S(o.mainContent),this.backdropOpacity=o.backdropOpacity,this.backdropOpacityRatio=1/o.backdropOpacity,this._emitOnOpen=o.onOpen,this._emitOnClose=o.onClose,this._emitOnChangeVisibility=o.onChangeVisibility,!a)try{this.transcludeContent()}catch(t){throw new Error("You must define an element with [sidebarjs] attribute")}this.setSwipeGestures(!0),(this.responsive||this.mainContent)&&this.setResponsive(),this.setPosition(o.position),this.addAttrsEventsListeners(this.component.getAttribute(s)),this.addTransitionListener(),this.backdrop.addEventListener("click",this.close,u)}return o(t,[{key:"isVisible",value:function(){return this.component.classList.contains(r)}},{key:"destroy",value:function(){var t=this;for(this.removeNativeGestures(),this.container.removeEventListener("transitionstart",this._onTransitionStart),this.container.removeEventListener("transitionend",this._onTransitionEnd),this.backdrop.removeEventListener("click",this.close),this.removeNativeOpenGestures(),this.removeAttrsEventsListeners(this.component.getAttribute(s)),this.removeComponentClassPosition();this.container.firstElementChild;)this.component.appendChild(this.container.firstElementChild);this.component.removeChild(this.container),this.component.removeChild(this.backdrop),Object.keys(this).forEach((function(e){return t[e]=null}))}},{key:"setPosition",value:function(t){var e=this;this.addComponentClass(c),this.position=l.indexOf(t)>=0?t:"left";var n=1===(document.querySelectorAll("[".concat(s,"]"))||[]).length;this.removeComponentClassPosition(n),this.addComponentClass("".concat(s,"--").concat(this.position)),this.responsive&&this.mainContent&&this.mainContent.classList.add("".concat(a,"--").concat(this.position)),setTimeout((function(){return e.component&&e.removeComponentClass(c)}),200)}},{key:"addAttrsEventsListeners",value:function(t){var e=this;C(t,(function(t,n){b(t)||(t.addEventListener("click",e[n],u),b(t,!0))}))}},{key:"removeAttrsEventsListeners",value:function(t){var e=this;C(t,(function(t,n){b(t)&&(t.removeEventListener("click",e[n]),b(t,!1))}))}},{key:"setSwipeGestures",value:function(t){if("boolean"!=typeof t)throw new Error("You provided a ".concat(e(t)," value but setSwipeGestures needs a boolean value."));this.nativeSwipe&&(t?this.addNativeGestures():this.removeNativeGestures(),this.nativeSwipeOpen&&(t?this.addNativeOpenGestures():this.removeNativeOpenGestures()))}},{key:"getTransitionType",value:function(){var t=this.isVisible();return{open:t&&!this._wasVisible,close:!t&&this._wasVisible,isVisible:t}}},{key:"toggleTransitionClass",value:function(t){this.toggleComponentClass("sidebarjs--transition-end",!t),this.toggleComponentClass("sidebarjs--transition-start",t)}},{key:"addTransitionListener",value:function(){this._wasVisible=this.isVisible(),this.container.addEventListener("transitionstart",this._onTransitionStart,u),this.container.addEventListener("transitionend",this._onTransitionEnd,u)}},{key:"removeComponentClassPosition",value:function(t){for(var e=0;e