Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 2985d9e

Browse files
committed
build(version): update sidebarjs dependecy
1 parent e65933a commit 2985d9e

3 files changed

Lines changed: 155 additions & 161 deletions

File tree

dist/angular-sidebarjs.js

Lines changed: 151 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,180 @@
11
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2-
'use strict';
3-
4-
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5-
6-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7-
8-
(function (sidebarjs) {
9-
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
10-
module.exports = sidebarjs;
11-
} else if (typeof define === 'function' && define.amd) {
12-
define([], function () {
13-
return sidebarjs;
14-
});
15-
} else {
16-
window.SidebarJS = sidebarjs;
17-
}
18-
})(function () {
19-
var sidebarjs = 'sidebarjs';
20-
var _isVisible = sidebarjs + '--is-visible';
21-
var isMoving = sidebarjs + '--is-moving';
22-
23-
return function () {
24-
function SidebarJS() {
25-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2+
(function (global, factory) {
3+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4+
typeof define === 'function' && define.amd ? define(factory) :
5+
(global.SidebarJS = factory());
6+
}(this, (function () { 'use strict';
267

27-
_classCallCheck(this, SidebarJS);
8+
function unwrapExports (x) {
9+
return x && x.__esModule ? x['default'] : x;
10+
}
2811

29-
this.component = options.component || document.querySelector('[' + sidebarjs + ']');
30-
this.container = options.container || SidebarJS.create(sidebarjs + '-container');
31-
this.background = options.background || SidebarJS.create(sidebarjs + '-background');
32-
this.documentMinSwipeX = options.documentMinSwipeX || 10;
33-
this.documentSwipeRange = options.documentSwipeRange || 40;
34-
this.nativeSwipe = options.nativeSwipe !== false;
35-
this.nativeSwipeOpen = options.nativeSwipeOpen !== false;
12+
function createCommonjsModule(fn, module) {
13+
return module = { exports: {} }, fn(module, module.exports), module.exports;
14+
}
3615

37-
if (!options.component && !options.container && !options.background) {
16+
var sidebarjs_1 = createCommonjsModule(function (module, exports) {
17+
"use strict";
18+
Object.defineProperty(exports, "__esModule", { value: true });
19+
var sidebarjs = 'sidebarjs';
20+
var isVisible = sidebarjs + "--is-visible";
21+
var isMoving = sidebarjs + "--is-moving";
22+
var SidebarJS = (function () {
23+
function SidebarJS(_a) {
24+
var _b = _a === void 0 ? {} : _a, component = _b.component, container = _b.container, background = _b.background, documentMinSwipeX = _b.documentMinSwipeX, documentSwipeRange = _b.documentSwipeRange, nativeSwipe = _b.nativeSwipe, nativeSwipeOpen = _b.nativeSwipeOpen;
25+
this.component = component || document.querySelector("[" + sidebarjs + "]");
26+
this.container = container || SidebarJS.create(sidebarjs + "-container");
27+
this.background = background || SidebarJS.create(sidebarjs + "-background");
28+
this.documentMinSwipeX = documentMinSwipeX || 10;
29+
this.documentSwipeRange = documentSwipeRange || 40;
30+
this.nativeSwipe = nativeSwipe !== false;
31+
this.nativeSwipeOpen = nativeSwipeOpen !== false;
32+
var hasAllConfigDOMElements = component && container && background;
33+
if (!hasAllConfigDOMElements) {
34+
try {
35+
this.transcludeContent();
36+
}
37+
catch (e) {
38+
throw new Error('You must define an element with [sidebarjs] attribute');
39+
}
40+
}
41+
if (this.nativeSwipe) {
42+
this.addNativeGestures();
43+
if (this.nativeSwipeOpen) {
44+
this.addNativeOpenGestures();
45+
}
46+
}
47+
this.addAttrsEventsListeners();
48+
this.background.addEventListener('click', this.close.bind(this));
49+
}
50+
SidebarJS.prototype.toggle = function () {
51+
this.component.classList.contains(isVisible) ? this.close() : this.open();
52+
};
53+
SidebarJS.prototype.open = function () {
54+
this.component.classList.add(isVisible);
55+
};
56+
SidebarJS.prototype.close = function () {
57+
this.component.classList.remove(isVisible);
58+
};
59+
SidebarJS.prototype.isVisible = function () {
60+
return this.component.classList.contains(isVisible);
61+
};
62+
SidebarJS.prototype.addAttrsEventsListeners = function () {
63+
var actions = ['toggle', 'open', 'close'];
64+
for (var i = 0; i < actions.length; i++) {
65+
var elements = document.querySelectorAll("[" + sidebarjs + "-" + actions[i] + "]");
66+
for (var j = 0; j < elements.length; j++) {
67+
if (!SidebarJS.elemHasListener(elements[j])) {
68+
elements[j].addEventListener('click', this[actions[i]].bind(this));
69+
SidebarJS.elemHasListener(elements[j], true);
70+
}
71+
}
72+
}
73+
};
74+
SidebarJS.prototype.transcludeContent = function () {
3875
this.container.innerHTML = this.component.innerHTML;
3976
this.component.innerHTML = '';
4077
this.component.appendChild(this.container);
4178
this.component.appendChild(this.background);
42-
}
43-
44-
if (this.nativeSwipe) {
79+
};
80+
SidebarJS.prototype.addNativeGestures = function () {
4581
this.component.addEventListener('touchstart', this.onTouchStart.bind(this));
4682
this.component.addEventListener('touchmove', this.onTouchMove.bind(this));
4783
this.component.addEventListener('touchend', this.onTouchEnd.bind(this));
48-
if (this.nativeSwipeOpen) {
49-
document.addEventListener('touchstart', this.onDocumentTouchStart.bind(this));
50-
document.addEventListener('touchmove', this.onDocumentTouchMove.bind(this));
51-
document.addEventListener('touchend', this.onDocumentTouchEnd.bind(this));
52-
}
53-
}
54-
55-
this.addAttrsEventsListeners();
56-
this.background.addEventListener('click', this.close.bind(this));
57-
}
58-
59-
_createClass(SidebarJS, [{
60-
key: 'addAttrsEventsListeners',
61-
value: function addAttrsEventsListeners() {
62-
var actions = ['toggle', 'open', 'close'];
63-
for (var i = 0; i < actions.length; i++) {
64-
var elements = document.querySelectorAll('[' + sidebarjs + '-' + actions[i] + ']');
65-
for (var j = 0; j < elements.length; j++) {
66-
if (!SidebarJS.elemHasListener(elements[j])) {
67-
elements[j].addEventListener('click', this[actions[i]].bind(this));
68-
SidebarJS.elemHasListener(elements[j], true);
69-
}
70-
}
71-
}
72-
}
73-
}, {
74-
key: 'onDocumentTouchStart',
75-
value: function onDocumentTouchStart(e) {
76-
if (e.touches[0].clientX < this.documentSwipeRange) {
77-
this.initialDocumentTouchX = e.touches[0].clientX;
78-
this.onTouchStart(e);
79-
}
80-
}
81-
}, {
82-
key: 'onDocumentTouchMove',
83-
value: function onDocumentTouchMove(e) {
84-
if (this.initialDocumentTouchX && !this.isVisible()) {
85-
var difference = e.touches[0].clientX - this.initialDocumentTouchX;
86-
if (difference > this.documentMinSwipeX) {
87-
this.movedDocumentTouchX = true;
88-
SidebarJS.vendorify(this.component, 'transform', 'translate(0, 0)');
89-
SidebarJS.vendorify(this.component, 'transition', 'none');
90-
this.onTouchMove(e);
91-
}
92-
}
93-
}
94-
}, {
95-
key: 'onDocumentTouchEnd',
96-
value: function onDocumentTouchEnd() {
97-
this.initialDocumentTouchX = 0;
98-
if (this.movedDocumentTouchX) {
99-
this.movedDocumentTouchX = 0;
100-
this.component.removeAttribute('style');
101-
this.onTouchEnd();
102-
}
103-
}
104-
}, {
105-
key: 'toggle',
106-
value: function toggle() {
107-
this.component.classList.contains(_isVisible) ? this.close() : this.open();
108-
}
109-
}, {
110-
key: 'open',
111-
value: function open() {
112-
this.component.classList.add(_isVisible);
113-
}
114-
}, {
115-
key: 'close',
116-
value: function close() {
117-
this.component.classList.remove(_isVisible);
118-
}
119-
}, {
120-
key: 'onTouchStart',
121-
value: function onTouchStart(e) {
122-
this.container.touchStart = e.touches[0].pageX;
123-
}
124-
}, {
125-
key: 'onTouchMove',
126-
value: function onTouchMove(e) {
127-
this.container.touchMove = this.container.touchStart - e.touches[0].pageX;
128-
this.container.touchMoveDocument = e.touches[0].pageX - this.container.clientWidth;
129-
if (this.container.touchMove >= 0 || this.movedDocumentTouchX && this.container.touchMoveDocument <= 0) {
130-
this.component.classList.add(isMoving);
131-
var movement = this.movedDocumentTouchX ? this.container.touchMoveDocument : -this.container.touchMove;
132-
SidebarJS.vendorify(this.container, 'transform', 'translate(' + movement + 'px, 0)');
133-
var opacity = 0.3 - -movement / (this.container.clientWidth * 3.5);
134-
this.background.style.opacity = opacity.toString();
84+
};
85+
SidebarJS.prototype.addNativeOpenGestures = function () {
86+
document.addEventListener('touchstart', this.onDocumentTouchStart.bind(this));
87+
document.addEventListener('touchmove', this.onDocumentTouchMove.bind(this));
88+
document.addEventListener('touchend', this.onDocumentTouchEnd.bind(this));
89+
};
90+
SidebarJS.prototype.onTouchStart = function (e) {
91+
this.initialTouch = e.touches[0].pageX;
92+
};
93+
SidebarJS.prototype.onTouchMove = function (e) {
94+
this.touchMoveSidebar = this.initialTouch - e.touches[0].pageX;
95+
if (this.touchMoveSidebar >= 0) {
96+
this.moveSidebar(-this.touchMoveSidebar);
13597
}
136-
}
137-
}, {
138-
key: 'onTouchEnd',
139-
value: function onTouchEnd() {
98+
};
99+
SidebarJS.prototype.onTouchEnd = function () {
140100
this.component.classList.remove(isMoving);
141-
this.container.touchMove > this.container.clientWidth / 3.5 ? this.close() : this.open();
142-
this.container.touchMove = 0;
101+
this.touchMoveSidebar > (this.container.clientWidth / 3.5) ? this.close() : this.open();
143102
this.container.removeAttribute('style');
144103
this.background.removeAttribute('style');
145-
}
146-
}, {
147-
key: 'isVisible',
148-
value: function isVisible() {
149-
return this.component.classList.contains(_isVisible);
150-
}
151-
}], [{
152-
key: 'create',
153-
value: function create(element) {
104+
delete this.initialTouch;
105+
delete this.touchMoveSidebar;
106+
};
107+
SidebarJS.prototype.moveSidebar = function (movement) {
108+
this.component.classList.add(isMoving);
109+
SidebarJS.vendorify(this.container, 'transform', "translate(" + movement + "px, 0)");
110+
this.changeBackgroundOpacity(movement);
111+
};
112+
SidebarJS.prototype.changeBackgroundOpacity = function (movement) {
113+
var opacity = 0.3 - (-movement / (this.container.clientWidth * 3.5));
114+
this.background.style.opacity = (opacity).toString();
115+
};
116+
SidebarJS.prototype.onDocumentTouchStart = function (e) {
117+
var touchPositionX = e.touches[0].clientX;
118+
if (touchPositionX < this.documentSwipeRange) {
119+
this.onTouchStart(e);
120+
}
121+
};
122+
SidebarJS.prototype.onDocumentTouchMove = function (e) {
123+
if (this.initialTouch && !this.isVisible()) {
124+
var documentSwiped = e.touches[0].clientX - this.initialTouch;
125+
if (documentSwiped > this.documentMinSwipeX) {
126+
this.touchMoveDocument = e.touches[0].pageX - this.container.clientWidth;
127+
SidebarJS.vendorify(this.component, 'transform', 'translate(0, 0)');
128+
SidebarJS.vendorify(this.component, 'transition', 'none');
129+
if (this.touchMoveDocument <= 0) {
130+
this.moveSidebar(this.touchMoveDocument);
131+
}
132+
}
133+
}
134+
};
135+
SidebarJS.prototype.onDocumentTouchEnd = function () {
136+
if (this.touchMoveDocument) {
137+
delete this.touchMoveDocument;
138+
this.component.removeAttribute('style');
139+
this.onTouchEnd();
140+
}
141+
};
142+
SidebarJS.create = function (element) {
154143
var el = document.createElement('div');
155144
el.setAttribute(element, '');
156145
return el;
157-
}
158-
}, {
159-
key: 'vendorify',
160-
value: function vendorify(el, prop, val) {
146+
};
147+
SidebarJS.vendorify = function (el, prop, val) {
161148
var Prop = prop.charAt(0).toUpperCase() + prop.slice(1);
162149
var prefs = ['Moz', 'Webkit', 'O', 'ms'];
163150
el.style[prop] = val;
164151
for (var i = 0; i < prefs.length; i++) {
165-
el.style[prefs[i] + Prop] = val;
152+
el.style[prefs[i] + Prop] = val;
166153
}
167154
return el;
168-
}
169-
}, {
170-
key: 'elemHasListener',
171-
value: function elemHasListener(elem, value) {
172-
return elem && value ? elem.sidebarjsListener = value : elem.sidebarjsListener;
173-
}
174-
}, {
175-
key: 'version',
176-
get: function get() {
177-
return '1.7.1';
178-
}
179-
}]);
180-
155+
};
156+
SidebarJS.elemHasListener = function (elem, value) {
157+
return elem && (value === true || value === false) ? elem.sidebarjsListener = value : !!elem.sidebarjsListener;
158+
};
159+
Object.defineProperty(SidebarJS, "version", {
160+
get: function () {
161+
return '1.9.0';
162+
},
163+
enumerable: true,
164+
configurable: true
165+
});
181166
return SidebarJS;
182-
}();
183167
}());
168+
exports.default = SidebarJS;
169+
170+
});
171+
172+
var sidebarjs = unwrapExports(sidebarjs_1);
173+
174+
return sidebarjs;
175+
176+
})));
177+
184178
},{}],2:[function(require,module,exports){
185179
module.exports = require('./dist/sidebarjs.js');
186180

0 commit comments

Comments
 (0)