@operato/utils 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.3.9](https://github.com/hatiolab/operato/compare/v0.3.8...v0.3.9) (2022-01-15)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * move @operato/board/utils to @operato/utils ([06ba865](https://github.com/hatiolab/operato/commit/06ba865ac70bd65166fd20b6d23cc5241d9fca17))
12
+
13
+
14
+
6
15
  ### [0.3.8](https://github.com/hatiolab/operato/compare/v0.3.7...v0.3.8) (2022-01-14)
7
16
 
8
17
  **Note:** Version bump only for package @operato/utils
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 풀스크린 전환 이후와 풀스크린 해제 이후에 호출되는 콜백함수
3
+ * @callback FullscreenCallback
4
+ */
5
+ export declare type FullscreenCallback = () => void;
6
+ /**
7
+ * 엘리먼트를 풀스크린으로 표시되도록 한다.
8
+ * @param {HTMLElement} element 대상 엘리먼트
9
+ * @param {FullscreenCallback} afterfull 풀스크린이 된 이후에 호출되는 콜백함수
10
+ * @param {FullscreenCallback} afterfinish 풀스크린이 해제된 이후에 호출되는 콜백함수
11
+ */
12
+ export declare function fullscreen(element: HTMLElement, afterfull?: FullscreenCallback, afterfinish?: FullscreenCallback): void;
13
+ export declare function exitfullscreen(): void;
14
+ export declare function togglefullscreen(element: HTMLElement, afterfull?: FullscreenCallback, afterfinish?: FullscreenCallback): void;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * 엘리먼트를 풀스크린으로 표시되도록 한다.
3
+ * @param {HTMLElement} element 대상 엘리먼트
4
+ * @param {FullscreenCallback} afterfull 풀스크린이 된 이후에 호출되는 콜백함수
5
+ * @param {FullscreenCallback} afterfinish 풀스크린이 해제된 이후에 호출되는 콜백함수
6
+ */
7
+ export function fullscreen(element, afterfull, afterfinish) {
8
+ var org_width = element.style.width;
9
+ var org_height = element.style.height;
10
+ function _fullscreen_callback(e) {
11
+ if (!document.fullscreenElement &&
12
+ //@ts-ignore
13
+ !document.mozFullScreen &&
14
+ //@ts-ignore
15
+ !document.webkitIsFullScreen &&
16
+ //@ts-ignore
17
+ !document.msFullscreenElement) {
18
+ ;
19
+ ['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event => document.removeEventListener(event, _fullscreen_callback));
20
+ element.style.width = org_width;
21
+ element.style.height = org_height;
22
+ afterfinish && afterfinish();
23
+ }
24
+ else {
25
+ element.style.width = '100%';
26
+ element.style.height = '100%';
27
+ afterfull && afterfull();
28
+ }
29
+ }
30
+ ;
31
+ ['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event => document.addEventListener(event, _fullscreen_callback));
32
+ if (element.requestFullscreen)
33
+ element.requestFullscreen();
34
+ //@ts-ignore
35
+ else if (element.webkitRequestFullScreen)
36
+ element.webkitRequestFullScreen();
37
+ //@ts-ignore
38
+ else if (element.mozRequestFullScreen)
39
+ element.mozRequestFullScreen();
40
+ //@ts-ignore
41
+ else if (element.msRequestFullscreen)
42
+ element.msRequestFullscreen();
43
+ }
44
+ export function exitfullscreen() {
45
+ if (document.exitFullscreen)
46
+ document.exitFullscreen();
47
+ //@ts-ignore
48
+ else if (document.mozCancelFullScreen)
49
+ document.mozCancelFullScreen();
50
+ //@ts-ignore
51
+ else if (document.webkitCancelFullScreen)
52
+ document.webkitCancelFullScreen();
53
+ //@ts-ignore
54
+ else if (document.msExitFullscreen)
55
+ document.msExitFullscreen();
56
+ }
57
+ export function togglefullscreen(element, afterfull, afterfinish) {
58
+ if (!document.fullscreenElement &&
59
+ //@ts-ignore
60
+ !document.mozFullScreen &&
61
+ //@ts-ignore
62
+ !document.webkitIsFullScreen &&
63
+ //@ts-ignore
64
+ !document.msFullscreenElement)
65
+ fullscreen(element, afterfull, afterfinish);
66
+ else
67
+ exitfullscreen();
68
+ }
69
+ //# sourceMappingURL=fullscreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen.js","sourceRoot":"","sources":["../../src/fullscreen.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,SAA8B,EAAE,WAAgC;IAC/G,IAAI,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;IACnC,IAAI,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAA;IAErC,SAAS,oBAAoB,CAAC,CAAQ;QACpC,IACE,CAAC,QAAQ,CAAC,iBAAiB;YAC3B,YAAY;YACZ,CAAC,QAAQ,CAAC,aAAa;YACvB,YAAY;YACZ,CAAC,QAAQ,CAAC,kBAAkB;YAC5B,YAAY;YACZ,CAAC,QAAQ,CAAC,mBAAmB,EAC7B;YACA,CAAC;YAAA,CAAC,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CACpF,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAC1D,CAAA;YAED,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA;YAC/B,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAA;YAEjC,WAAW,IAAI,WAAW,EAAE,CAAA;SAC7B;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAA;YAC5B,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;YAE7B,SAAS,IAAI,SAAS,EAAE,CAAA;SACzB;IACH,CAAC;IAED,CAAC;IAAA,CAAC,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CACpF,QAAQ,CAAC,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,CAAC,CACvD,CAAA;IAED,IAAI,OAAO,CAAC,iBAAiB;QAAE,OAAO,CAAC,iBAAiB,EAAE,CAAA;IAC1D,YAAY;SACP,IAAI,OAAO,CAAC,uBAAuB;QAAE,OAAO,CAAC,uBAAuB,EAAE,CAAA;IAC3E,YAAY;SACP,IAAI,OAAO,CAAC,oBAAoB;QAAE,OAAO,CAAC,oBAAoB,EAAE,CAAA;IACrE,YAAY;SACP,IAAI,OAAO,CAAC,mBAAmB;QAAE,OAAO,CAAC,mBAAmB,EAAE,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,QAAQ,CAAC,cAAc;QAAE,QAAQ,CAAC,cAAc,EAAE,CAAA;IACtD,YAAY;SACP,IAAI,QAAQ,CAAC,mBAAmB;QAAE,QAAQ,CAAC,mBAAmB,EAAE,CAAA;IACrE,YAAY;SACP,IAAI,QAAQ,CAAC,sBAAsB;QAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAA;IAC3E,YAAY;SACP,IAAI,QAAQ,CAAC,gBAAgB;QAAE,QAAQ,CAAC,gBAAgB,EAAE,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,OAAoB,EACpB,SAA8B,EAC9B,WAAgC;IAEhC,IACE,CAAC,QAAQ,CAAC,iBAAiB;QAC3B,YAAY;QACZ,CAAC,QAAQ,CAAC,aAAa;QACvB,YAAY;QACZ,CAAC,QAAQ,CAAC,kBAAkB;QAC5B,YAAY;QACZ,CAAC,QAAQ,CAAC,mBAAmB;QAE7B,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;;QACxC,cAAc,EAAE,CAAA;AACvB,CAAC","sourcesContent":["/**\n * 풀스크린 전환 이후와 풀스크린 해제 이후에 호출되는 콜백함수\n * @callback FullscreenCallback\n */\nexport type FullscreenCallback = () => void\n\n/**\n * 엘리먼트를 풀스크린으로 표시되도록 한다.\n * @param {HTMLElement} element 대상 엘리먼트\n * @param {FullscreenCallback} afterfull 풀스크린이 된 이후에 호출되는 콜백함수\n * @param {FullscreenCallback} afterfinish 풀스크린이 해제된 이후에 호출되는 콜백함수\n */\nexport function fullscreen(element: HTMLElement, afterfull?: FullscreenCallback, afterfinish?: FullscreenCallback) {\n var org_width = element.style.width\n var org_height = element.style.height\n\n function _fullscreen_callback(e: Event) {\n if (\n !document.fullscreenElement &&\n //@ts-ignore\n !document.mozFullScreen &&\n //@ts-ignore\n !document.webkitIsFullScreen &&\n //@ts-ignore\n !document.msFullscreenElement\n ) {\n ;['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event =>\n document.removeEventListener(event, _fullscreen_callback)\n )\n\n element.style.width = org_width\n element.style.height = org_height\n\n afterfinish && afterfinish()\n } else {\n element.style.width = '100%'\n element.style.height = '100%'\n\n afterfull && afterfull()\n }\n }\n\n ;['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event =>\n document.addEventListener(event, _fullscreen_callback)\n )\n\n if (element.requestFullscreen) element.requestFullscreen()\n //@ts-ignore\n else if (element.webkitRequestFullScreen) element.webkitRequestFullScreen()\n //@ts-ignore\n else if (element.mozRequestFullScreen) element.mozRequestFullScreen()\n //@ts-ignore\n else if (element.msRequestFullscreen) element.msRequestFullscreen()\n}\n\nexport function exitfullscreen() {\n if (document.exitFullscreen) document.exitFullscreen()\n //@ts-ignore\n else if (document.mozCancelFullScreen) document.mozCancelFullScreen()\n //@ts-ignore\n else if (document.webkitCancelFullScreen) document.webkitCancelFullScreen()\n //@ts-ignore\n else if (document.msExitFullscreen) document.msExitFullscreen()\n}\n\nexport function togglefullscreen(\n element: HTMLElement,\n afterfull?: FullscreenCallback,\n afterfinish?: FullscreenCallback\n) {\n if (\n !document.fullscreenElement &&\n //@ts-ignore\n !document.mozFullScreen &&\n //@ts-ignore\n !document.webkitIsFullScreen &&\n //@ts-ignore\n !document.msFullscreenElement\n )\n fullscreen(element, afterfull, afterfinish)\n else exitfullscreen()\n}\n"]}
@@ -1,3 +1,6 @@
1
1
  export * from './sleep.js';
2
2
  export * from './file-drop-helper.js';
3
3
  export * from './context-path.js';
4
+ export * from './os.js';
5
+ export * from './swipe-listener.js';
6
+ export * from './fullscreen.js';
package/dist/src/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from './sleep.js';
2
2
  export * from './file-drop-helper.js';
3
3
  export * from './context-path.js';
4
+ export * from './os.js';
5
+ export * from './swipe-listener.js';
6
+ export * from './fullscreen.js';
4
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA","sourcesContent":["export * from './sleep.js'\nexport * from './file-drop-helper.js'\nexport * from './context-path.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA","sourcesContent":["export * from './sleep.js'\nexport * from './file-drop-helper.js'\nexport * from './context-path.js'\nexport * from './os.js'\nexport * from './swipe-listener.js'\nexport * from './fullscreen.js'\n"]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * method to get operating system of running browser
3
+ * @returns {string} name of OS : 'Windows | 'Mac' | 'Android' | 'iOS'
4
+ */
5
+ export declare function getOS(): string;
6
+ /**
7
+ * method to tell if platform of running browser is kind of mobile device
8
+ * @returns {boolean}
9
+ */
10
+ export declare function isMobileDevice(): boolean;
11
+ /**
12
+ * method to tell if operating system of running browser is iOS
13
+ * @returns {boolean}
14
+ */
15
+ export declare function isIOS(): boolean;
16
+ /**
17
+ * method to tell if operating system of running browser is MacOS
18
+ * @returns {boolean}
19
+ */
20
+ export declare function isMacOS(): boolean;
21
+ export declare function isSafari(): false | RegExpMatchArray | null;
package/dist/src/os.js ADDED
@@ -0,0 +1,44 @@
1
+ var os = 'Unknown OS';
2
+ if (navigator.userAgent.indexOf('Win') != -1)
3
+ os = 'Windows';
4
+ else if (navigator.userAgent.indexOf('Mac') != -1)
5
+ os = 'Mac';
6
+ else if (navigator.userAgent.indexOf('Linux') != -1)
7
+ os = 'Linux';
8
+ else if (navigator.userAgent.indexOf('Android') != -1)
9
+ os = 'Android';
10
+ else if (navigator.userAgent.indexOf('like Mac') != -1)
11
+ os = 'iOS';
12
+ var mobile = os === 'iOS' || os === 'Android';
13
+ /**
14
+ * method to get operating system of running browser
15
+ * @returns {string} name of OS : 'Windows | 'Mac' | 'Android' | 'iOS'
16
+ */
17
+ export function getOS() {
18
+ return os;
19
+ }
20
+ /**
21
+ * method to tell if platform of running browser is kind of mobile device
22
+ * @returns {boolean}
23
+ */
24
+ export function isMobileDevice() {
25
+ return mobile;
26
+ }
27
+ /**
28
+ * method to tell if operating system of running browser is iOS
29
+ * @returns {boolean}
30
+ */
31
+ export function isIOS() {
32
+ return os === 'iOS';
33
+ }
34
+ /**
35
+ * method to tell if operating system of running browser is MacOS
36
+ * @returns {boolean}
37
+ */
38
+ export function isMacOS() {
39
+ return os === 'Mac';
40
+ }
41
+ export function isSafari() {
42
+ return !navigator.userAgent.match(/chrome|chromium|crios/i) && navigator.userAgent.match(/safari/i);
43
+ }
44
+ //# sourceMappingURL=os.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.js","sourceRoot":"","sources":["../../src/os.ts"],"names":[],"mappings":"AAAA,IAAI,EAAE,GAAG,YAAY,CAAA;AAErB,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAAE,EAAE,GAAG,SAAS,CAAA;KACvD,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAAE,EAAE,GAAG,KAAK,CAAA;KACxD,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAAE,EAAE,GAAG,OAAO,CAAA;KAC5D,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAAE,EAAE,GAAG,SAAS,CAAA;KAChE,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAAE,EAAE,GAAG,KAAK,CAAA;AAElE,IAAI,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,SAAS,CAAA;AAE7C;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,EAAE,CAAA;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,EAAE,KAAK,KAAK,CAAA;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO;IACrB,OAAO,EAAE,KAAK,KAAK,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;AACrG,CAAC","sourcesContent":["var os = 'Unknown OS'\n\nif (navigator.userAgent.indexOf('Win') != -1) os = 'Windows'\nelse if (navigator.userAgent.indexOf('Mac') != -1) os = 'Mac'\nelse if (navigator.userAgent.indexOf('Linux') != -1) os = 'Linux'\nelse if (navigator.userAgent.indexOf('Android') != -1) os = 'Android'\nelse if (navigator.userAgent.indexOf('like Mac') != -1) os = 'iOS'\n\nvar mobile = os === 'iOS' || os === 'Android'\n\n/**\n * method to get operating system of running browser\n * @returns {string} name of OS : 'Windows | 'Mac' | 'Android' | 'iOS'\n */\nexport function getOS() {\n return os\n}\n\n/**\n * method to tell if platform of running browser is kind of mobile device\n * @returns {boolean}\n */\nexport function isMobileDevice() {\n return mobile\n}\n\n/**\n * method to tell if operating system of running browser is iOS\n * @returns {boolean}\n */\nexport function isIOS() {\n return os === 'iOS'\n}\n\n/**\n * method to tell if operating system of running browser is MacOS\n * @returns {boolean}\n */\nexport function isMacOS() {\n return os === 'Mac'\n}\n\nexport function isSafari() {\n return !navigator.userAgent.match(/chrome|chromium|crios/i) && navigator.userAgent.match(/safari/i)\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Starts monitoring swipes on the given element and
3
+ * emits `swipe` event when a swipe gesture is performed.
4
+ * @param {DOMElement} element Element on which to listen for swipe gestures.
5
+ * @param {Object} options Optional: Options.
6
+ * @return {Object}
7
+ */
8
+ export declare function SwipeListener(element: HTMLElement, options?: any): {
9
+ off: () => void;
10
+ } | undefined;
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Starts monitoring swipes on the given element and
3
+ * emits `swipe` event when a swipe gesture is performed.
4
+ * @param {DOMElement} element Element on which to listen for swipe gestures.
5
+ * @param {Object} options Optional: Options.
6
+ * @return {Object}
7
+ */
8
+ export function SwipeListener(element, options) {
9
+ if (!element)
10
+ return;
11
+ // CustomEvent polyfill
12
+ if (typeof window !== 'undefined') {
13
+ ;
14
+ (function () {
15
+ if (typeof window.CustomEvent === 'function')
16
+ return false;
17
+ function CustomEvent(event, params) {
18
+ params = params || { bubbles: false, cancelable: false, detail: undefined };
19
+ var evt = document.createEvent('CustomEvent');
20
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
21
+ return evt;
22
+ }
23
+ CustomEvent.prototype = window.Event.prototype;
24
+ window.CustomEvent = CustomEvent;
25
+ })();
26
+ }
27
+ let defaultOpts = {
28
+ minHorizontal: 10,
29
+ minVertical: 10,
30
+ deltaHorizontal: 3,
31
+ deltaVertical: 5,
32
+ preventScroll: false,
33
+ lockAxis: true,
34
+ touch: true,
35
+ mouse: true // Listen for mouse events
36
+ };
37
+ // Set options
38
+ if (!options) {
39
+ options = {};
40
+ }
41
+ options = {
42
+ ...defaultOpts,
43
+ ...options
44
+ };
45
+ // Store the touches
46
+ let touches = [];
47
+ // Not dragging by default.
48
+ let dragging = false;
49
+ // When mouse-click is started, make dragging true.
50
+ const _mousedown = function (e) {
51
+ dragging = true;
52
+ };
53
+ // When mouse-click is released, make dragging false and signify end by imitating `touchend`.
54
+ const _mouseup = function (e) {
55
+ dragging = false;
56
+ _touchend(e);
57
+ };
58
+ // When mouse is moved while being clicked, imitate a `touchmove`.
59
+ const _mousemove = function (e) {
60
+ if (dragging) {
61
+ ;
62
+ e.changedTouches = [
63
+ {
64
+ clientX: e.clientX,
65
+ clientY: e.clientY
66
+ }
67
+ ];
68
+ _touchmove(e);
69
+ }
70
+ };
71
+ if (options.mouse) {
72
+ element.addEventListener('mousedown', _mousedown);
73
+ element.addEventListener('mouseup', _mouseup);
74
+ element.addEventListener('mousemove', _mousemove);
75
+ }
76
+ // When the swipe is completed, calculate the direction.
77
+ const _touchend = function (e) {
78
+ if (!touches.length)
79
+ return;
80
+ const touch = typeof TouchEvent === 'function' && e instanceof TouchEvent;
81
+ let x = [], y = [];
82
+ let directions = {
83
+ top: false,
84
+ right: false,
85
+ bottom: false,
86
+ left: false
87
+ };
88
+ for (let i = 0; i < touches.length; i++) {
89
+ x.push(touches[i].x);
90
+ y.push(touches[i].y);
91
+ }
92
+ const xs = x[0], xe = x[x.length - 1], // Start and end x-coords
93
+ ys = y[0], ye = y[y.length - 1]; // Start and end y-coords
94
+ const eventCoords = {
95
+ x: [xs, xe],
96
+ y: [ys, ye]
97
+ };
98
+ if (touches.length > 1) {
99
+ const swipeReleaseEventData = {
100
+ detail: {
101
+ touch,
102
+ target: e.target,
103
+ ...eventCoords
104
+ }
105
+ };
106
+ let swipeReleaseEvent = new CustomEvent('swiperelease', swipeReleaseEventData);
107
+ element.dispatchEvent(swipeReleaseEvent);
108
+ }
109
+ // Determine left or right
110
+ let diff = x[0] - x[x.length - 1];
111
+ let swipe = 'none';
112
+ if (diff > 0) {
113
+ swipe = 'left';
114
+ }
115
+ else {
116
+ swipe = 'right';
117
+ }
118
+ let min = Math.min(...x), max = Math.max(...x), _diff;
119
+ // If minimum horizontal distance was travelled
120
+ if (Math.abs(diff) >= options.minHorizontal) {
121
+ switch (swipe) {
122
+ case 'left':
123
+ _diff = Math.abs(min - x[x.length - 1]);
124
+ if (_diff <= options.deltaHorizontal) {
125
+ directions.left = true;
126
+ }
127
+ break;
128
+ case 'right':
129
+ _diff = Math.abs(max - x[x.length - 1]);
130
+ if (_diff <= options.deltaHorizontal) {
131
+ directions.right = true;
132
+ }
133
+ break;
134
+ }
135
+ }
136
+ // Determine top or bottom
137
+ diff = y[0] - y[y.length - 1];
138
+ swipe = 'none';
139
+ if (diff > 0) {
140
+ swipe = 'top';
141
+ }
142
+ else {
143
+ swipe = 'bottom';
144
+ }
145
+ min = Math.min(...y);
146
+ max = Math.max(...y);
147
+ // If minimum vertical distance was travelled
148
+ if (Math.abs(diff) >= options.minVertical) {
149
+ switch (swipe) {
150
+ case 'top':
151
+ _diff = Math.abs(min - y[y.length - 1]);
152
+ if (_diff <= options.deltaVertical) {
153
+ directions.top = true;
154
+ }
155
+ break;
156
+ case 'bottom':
157
+ _diff = Math.abs(max - y[y.length - 1]);
158
+ if (_diff <= options.deltaVertical) {
159
+ directions.bottom = true;
160
+ }
161
+ break;
162
+ }
163
+ }
164
+ // Clear touches array.
165
+ touches = [];
166
+ // If there is a swipe direction, emit an event.
167
+ if (directions.top || directions.right || directions.bottom || directions.left) {
168
+ /**
169
+ * If lockAxis is true, determine which axis to select.
170
+ * The axis with the most travel is selected.
171
+ * TODO: Factor in for the orientation of the device
172
+ * and use it as a weight to determine the travel along an axis.
173
+ */
174
+ if (options.lockAxis) {
175
+ if ((directions.left || directions.right) && Math.abs(xs - xe) > Math.abs(ys - ye)) {
176
+ directions.top = directions.bottom = false;
177
+ }
178
+ else if ((directions.top || directions.bottom) && Math.abs(xs - xe) < Math.abs(ys - ye)) {
179
+ directions.left = directions.right = false;
180
+ }
181
+ }
182
+ const eventData = {
183
+ detail: {
184
+ directions,
185
+ touch,
186
+ target: e.target,
187
+ ...eventCoords
188
+ }
189
+ };
190
+ let event = new CustomEvent('swipe', eventData);
191
+ element.dispatchEvent(event);
192
+ }
193
+ else {
194
+ let cancelEvent = new CustomEvent('swipecancel', {
195
+ detail: {
196
+ touch,
197
+ target: e.target,
198
+ ...eventCoords
199
+ }
200
+ });
201
+ element.dispatchEvent(cancelEvent);
202
+ }
203
+ };
204
+ // When a swipe is performed, store the coords.
205
+ const _touchmove = function (e) {
206
+ let touch = e.changedTouches[0];
207
+ touches.push({
208
+ x: touch.clientX,
209
+ y: touch.clientY
210
+ });
211
+ // Emit a `swiping` event if there are more than one touch-points.
212
+ if (touches.length > 1) {
213
+ const xs = touches[0].x, // Start and end x-coords
214
+ xe = touches[touches.length - 1].x, ys = touches[0].y, // Start and end y-coords
215
+ ye = touches[touches.length - 1].y, eventData = {
216
+ detail: {
217
+ x: [xs, xe],
218
+ y: [ys, ye],
219
+ touch: typeof TouchEvent === 'function' && e instanceof TouchEvent,
220
+ target: e.target
221
+ }
222
+ };
223
+ let event = new CustomEvent('swiping', eventData);
224
+ const shouldPrevent = options.preventScroll === true || (typeof options.preventScroll === 'function' && options.preventScroll(event));
225
+ if (shouldPrevent) {
226
+ e.preventDefault();
227
+ }
228
+ element.dispatchEvent(event);
229
+ }
230
+ };
231
+ // Test via a getter in the options object to see if the passive property is accessed
232
+ let passiveOptions = false;
233
+ try {
234
+ const testOptions = Object.defineProperty({}, 'passive', {
235
+ get: function () {
236
+ passiveOptions = { passive: !options.preventScroll };
237
+ }
238
+ });
239
+ window.addEventListener('testPassive', null, testOptions);
240
+ window.removeEventListener('testPassive', null, testOptions);
241
+ }
242
+ catch (e) { }
243
+ if (options.touch) {
244
+ element.addEventListener('touchmove', _touchmove, passiveOptions);
245
+ element.addEventListener('touchend', _touchend);
246
+ }
247
+ return {
248
+ off: function () {
249
+ element.removeEventListener('touchmove', _touchmove, passiveOptions);
250
+ element.removeEventListener('touchend', _touchend);
251
+ element.removeEventListener('mousedown', _mousedown);
252
+ element.removeEventListener('mouseup', _mouseup);
253
+ element.removeEventListener('mousemove', _mousemove);
254
+ }
255
+ };
256
+ }
257
+ //# sourceMappingURL=swipe-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipe-listener.js","sourceRoot":"","sources":["../../src/swipe-listener.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,OAAoB,EAAE,OAAa;IAC/D,IAAI,CAAC,OAAO;QAAE,OAAM;IAEpB,uBAAuB;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,CAAC;QAAA,CAAC;YACA,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU;gBAAE,OAAO,KAAK,CAAA;YAC1D,SAAS,WAAW,CAAC,KAAa,EAAE,MAAW;gBAC7C,MAAM,GAAG,MAAM,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;gBAC3E,IAAI,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;gBAC7C,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;gBAC5E,OAAO,GAAG,CAAA;YACZ,CAAC;YACD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAC7C;YAAC,MAAc,CAAC,WAAW,GAAG,WAAW,CAAA;QAC5C,CAAC,CAAC,EAAE,CAAA;KACL;IAED,IAAI,WAAW,GAAG;QAChB,aAAa,EAAE,EAAE;QACjB,WAAW,EAA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CAAA;KACpE;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC,CAAA;QACjE,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;KAChD;IAED,OAAO;QACL,GAAG,EAAE;YACH,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC,CAAA;YACpE,OAAO,CAAC,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YAClD,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;YACpD,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;YAChD,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Starts monitoring swipes on the given element and\n * emits `swipe` event when a swipe gesture is performed.\n * @param {DOMElement} element Element on which to listen for swipe gestures.\n * @param {Object} options Optional: Options.\n * @return {Object}\n */\nexport function SwipeListener(element: HTMLElement, options?: any) {\n if (!element) return\n\n // CustomEvent polyfill\n if (typeof window !== 'undefined') {\n ;(function () {\n if (typeof window.CustomEvent === 'function') return false\n function CustomEvent(event: string, params: any) {\n params = params || { bubbles: false, cancelable: false, detail: undefined }\n var evt = document.createEvent('CustomEvent')\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)\n return evt\n }\n CustomEvent.prototype = window.Event.prototype\n ;(window as any).CustomEvent = CustomEvent\n })()\n }\n\n let defaultOpts = {\n minHorizontal: 10, // Minimum number of pixels traveled to count as a horizontal swipe.\n minVertical: 10, // Minimum number of pixels traveled to count as a vertical swipe.\n deltaHorizontal: 3, // Delta for horizontal swipe\n deltaVertical: 5, // Delta for vertical swipe\n preventScroll: false, // Prevents scrolling when swiping.\n lockAxis: true, // Select only one axis to be true instead of multiple.\n touch: true, // Listen for touch events\n mouse: true // Listen for mouse events\n }\n\n // Set options\n if (!options) {\n options = {}\n }\n options = {\n ...defaultOpts,\n ...options\n }\n\n // Store the touches\n let touches: Array<{ x: number; y: number }> = []\n\n // Not dragging by default.\n let dragging = false\n\n // When mouse-click is started, make dragging true.\n const _mousedown = function (e: MouseEvent) {\n dragging = true\n }\n\n // When mouse-click is released, make dragging false and signify end by imitating `touchend`.\n const _mouseup = function (e: MouseEvent) {\n dragging = false\n _touchend(e as any)\n }\n\n // When mouse is moved while being clicked, imitate a `touchmove`.\n const _mousemove = function (e: MouseEvent) {\n if (dragging) {\n ;(e as any).changedTouches = [\n {\n clientX: e.clientX,\n clientY: e.clientY\n }\n ]\n _touchmove(e as any)\n }\n }\n\n if (options.mouse) {\n element.addEventListener('mousedown', _mousedown)\n element.addEventListener('mouseup', _mouseup)\n element.addEventListener('mousemove', _mousemove)\n }\n\n // When the swipe is completed, calculate the direction.\n const _touchend = function (e: TouchEvent) {\n if (!touches.length) return\n\n const touch = typeof TouchEvent === 'function' && e instanceof TouchEvent\n\n let x = [],\n y = []\n\n let directions = {\n top: false,\n right: false,\n bottom: false,\n left: false\n }\n\n for (let i = 0; i < touches.length; i++) {\n x.push(touches[i].x)\n y.push(touches[i].y)\n }\n\n const xs = x[0],\n xe = x[x.length - 1], // Start and end x-coords\n ys = y[0],\n ye = y[y.length - 1] // Start and end y-coords\n\n const eventCoords = {\n x: [xs, xe],\n y: [ys, ye]\n }\n\n if (touches.length > 1) {\n const swipeReleaseEventData = {\n detail: {\n touch,\n target: e.target,\n ...eventCoords\n }\n }\n\n let swipeReleaseEvent = new CustomEvent('swiperelease', swipeReleaseEventData)\n element.dispatchEvent(swipeReleaseEvent)\n }\n\n // Determine left or right\n let diff = x[0] - x[x.length - 1]\n let swipe = 'none'\n if (diff > 0) {\n swipe = 'left'\n } else {\n swipe = 'right'\n }\n\n let min = Math.min(...x),\n max = Math.max(...x),\n _diff\n\n // If minimum horizontal distance was travelled\n if (Math.abs(diff) >= options.minHorizontal) {\n switch (swipe) {\n case 'left':\n _diff = Math.abs(min - x[x.length - 1])\n if (_diff <= options.deltaHorizontal) {\n directions.left = true\n }\n break\n case 'right':\n _diff = Math.abs(max - x[x.length - 1])\n if (_diff <= options.deltaHorizontal) {\n directions.right = true\n }\n break\n }\n }\n\n // Determine top or bottom\n diff = y[0] - y[y.length - 1]\n swipe = 'none'\n if (diff > 0) {\n swipe = 'top'\n } else {\n swipe = 'bottom'\n }\n\n min = Math.min(...y)\n max = Math.max(...y)\n\n // If minimum vertical distance was travelled\n if (Math.abs(diff) >= options.minVertical) {\n switch (swipe) {\n case 'top':\n _diff = Math.abs(min - y[y.length - 1])\n if (_diff <= options.deltaVertical) {\n directions.top = true\n }\n break\n case 'bottom':\n _diff = Math.abs(max - y[y.length - 1])\n if (_diff <= options.deltaVertical) {\n directions.bottom = true\n }\n break\n }\n }\n\n // Clear touches array.\n touches = []\n\n // If there is a swipe direction, emit an event.\n if (directions.top || directions.right || directions.bottom || directions.left) {\n /**\n * If lockAxis is true, determine which axis to select.\n * The axis with the most travel is selected.\n * TODO: Factor in for the orientation of the device\n * and use it as a weight to determine the travel along an axis.\n */\n if (options.lockAxis) {\n if ((directions.left || directions.right) && Math.abs(xs - xe) > Math.abs(ys - ye)) {\n directions.top = directions.bottom = false\n } else if ((directions.top || directions.bottom) && Math.abs(xs - xe) < Math.abs(ys - ye)) {\n directions.left = directions.right = false\n }\n }\n\n const eventData = {\n detail: {\n directions,\n touch,\n target: e.target,\n ...eventCoords\n }\n }\n\n let event = new CustomEvent('swipe', eventData)\n element.dispatchEvent(event)\n } else {\n let cancelEvent = new CustomEvent('swipecancel', {\n detail: {\n touch,\n target: e.target,\n ...eventCoords\n }\n })\n element.dispatchEvent(cancelEvent)\n }\n }\n\n // When a swipe is performed, store the coords.\n const _touchmove = function (e: TouchEvent) {\n let touch = e.changedTouches[0]\n touches.push({\n x: touch.clientX,\n y: touch.clientY\n })\n\n // Emit a `swiping` event if there are more than one touch-points.\n if (touches.length > 1) {\n const xs = touches[0].x, // Start and end x-coords\n xe = touches[touches.length - 1].x,\n ys = touches[0].y, // Start and end y-coords\n ye = touches[touches.length - 1].y,\n eventData = {\n detail: {\n x: [xs, xe],\n y: [ys, ye],\n touch: typeof TouchEvent === 'function' && e instanceof TouchEvent,\n target: e.target\n }\n }\n let event = new CustomEvent('swiping', eventData)\n\n const shouldPrevent =\n options.preventScroll === true || (typeof options.preventScroll === 'function' && options.preventScroll(event))\n\n if (shouldPrevent) {\n e.preventDefault()\n }\n\n element.dispatchEvent(event)\n }\n }\n\n // Test via a getter in the options object to see if the passive property is accessed\n let passiveOptions: any = false\n try {\n const testOptions = Object.defineProperty({}, 'passive', {\n get: function () {\n passiveOptions = { passive: !options.preventScroll }\n }\n })\n window.addEventListener('testPassive', null as any, testOptions)\n window.removeEventListener('testPassive', null as any, testOptions)\n } catch (e) {}\n\n if (options.touch) {\n element.addEventListener('touchmove', _touchmove, passiveOptions)\n element.addEventListener('touchend', _touchend)\n }\n\n return {\n off: function () {\n element.removeEventListener('touchmove', _touchmove, passiveOptions)\n element.removeEventListener('touchend', _touchend)\n element.removeEventListener('mousedown', _mousedown)\n element.removeEventListener('mouseup', _mouseup)\n element.removeEventListener('mousemove', _mousemove)\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../src/context-path.ts","../src/file-drop-helper.ts","../src/sleep.ts","../src/index.ts","../../../node_modules/@types/lodash/common/common.d.ts","../../../node_modules/@types/lodash/common/array.d.ts","../../../node_modules/@types/lodash/common/collection.d.ts","../../../node_modules/@types/lodash/common/date.d.ts","../../../node_modules/@types/lodash/common/function.d.ts","../../../node_modules/@types/lodash/common/lang.d.ts","../../../node_modules/@types/lodash/common/math.d.ts","../../../node_modules/@types/lodash/common/number.d.ts","../../../node_modules/@types/lodash/common/object.d.ts","../../../node_modules/@types/lodash/common/seq.d.ts","../../../node_modules/@types/lodash/common/string.d.ts","../../../node_modules/@types/lodash/common/util.d.ts","../../../node_modules/@types/lodash/index.d.ts","../../../node_modules/@types/lodash/debounce.d.ts","../src/mixins/infinite-scrollable.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/mocha/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","a84f74a36313258ea3bf2fa085568a35530a423035037be03ce67e02c768787f","69ef8de8a4e2551f1a0e21d82a04d233fb5d7d8a1f8db661a1a18e880b4e7545","d9e51838c1aa2a91b7d2a495adb92ab70eb35c81fcd3b359c2509903958bf3f8","e88c06d2bb230fc61eed829bdd07c0185dbb6a596e55931e3aadb712110ec067","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","fe4a2042d087990ebfc7dc0142d5aaf5a152e4baea86b45f283f103ec1e871ea","d88a479cccf787b4aa82362150fbeba5211a32dbfafa7b92ba6995ecaf9a1a89","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","ae9930989ed57478eb03b9b80ad3efa7a3eacdfeff0f78ecf7894c4963a64f93","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","6ac6f24aff52e62c3950461aa17eab26e3a156927858e6b654baef0058b4cd1e",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"a5f9563c1315cffbc1e73072d96dcd42332f4eebbdffd7c3e904f545c9e9fe24","1d12501ae0fc9ed02db30f621fb6f82fdf3fea76b0c82300a86ad7b7e61f8a79","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"c2ab70bbc7a24c42a790890739dd8a0ba9d2e15038b40dff8163a97a5d148c00","affectsGlobalScope":true},"422dbb183fdced59425ca072c8bd09efaa77ce4e2ab928ec0d8a1ce062d2a45a",{"version":"2a801b0322994c3dd7f0ef30265d19b3dd3bae6d793596879166ed6219c3da68","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","bcc8caf03ee65fe8610d258752f255fbdddbb2e4de7b6c5628956a5a0d859ec8","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","cc0b61316c4f37393f1f9595e93b673f4184e9d07f4c127165a490ec4a928668","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"c28e5baab1b53377c90d12970e207a2644bc3627840066449e37e2a59125d07e","affectsGlobalScope":true},"7a5459efa09ea82088234e6533a203d528c594b01787fb90fba148885a36e8b6","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","fce6a1a1553ff7d54ffb8bb3ae488c9cb5f2f4f4e52212c1abe40f544819ef35","ad41bb744149e92adb06eb953da195115620a3f2ad48e7d3ae04d10762dae197","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"5d0a9ea09d990b5788f867f1c79d4878f86f7384cb7dab38eecbf22f9efd063d","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","00fa7ce8bc8acc560dc341bbfdf37840a8c59e6a67c9bfa3fa5f36254df35db2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"cfe724f7c694aab65a9bdd1acb05997848c504548c9d4c71645c187a091cfa2a","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"3345c276cab0e76dda86c0fb79104ff915a4580ba0f3e440870e183b1baec476","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","e383ff72aabf294913f8c346f5da1445ae6ad525836d28efd52cbadc01a361a6","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7","1835259a20b9fa6b1882931375b69ae5978195f2b139b4e0db51ec8319261649","b52cd693219a63dd21282ac99a7bf55f77cbe8a91f097968856419cc2e05f017","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"267af67ea520cabd16402522756b19ac63d9e2c1c86e7c4d1ddeb991c32e12c9",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5,"useDefineForClassFields":false},"fileIdsList":[[45,47,48,49,50,51,52,53,54,55,56,57,103],[45,46,48,49,50,51,52,53,54,55,56,57,103],[46,47,48,49,50,51,52,53,54,55,56,57,103],[45,46,47,49,50,51,52,53,54,55,56,57,103],[45,46,47,48,50,51,52,53,54,55,56,57,103],[45,46,47,48,49,51,52,53,54,55,56,57,103],[45,46,47,48,49,50,52,53,54,55,56,57,103],[45,46,47,48,49,50,51,53,54,55,56,57,103],[45,46,47,48,49,50,51,52,54,55,56,57,103],[45,46,47,48,49,50,51,52,53,55,56,57,103],[45,46,47,48,49,50,51,52,53,54,56,57,103],[45,46,47,48,49,50,51,52,53,54,55,57,103],[57,103],[45,46,47,48,49,50,51,52,53,54,55,56,103],[103],[60,103],[63,103],[64,69,103],[65,75,76,83,92,102,103],[65,66,75,83,103],[67,103],[68,69,76,84,103],[69,92,99,103],[70,72,75,83,103],[71,103],[72,73,103],[74,75,103],[75,103],[75,76,77,92,102,103],[75,76,77,92,103],[78,83,92,102,103],[75,76,78,79,83,92,99,102,103],[78,80,92,99,102,103],[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109],[75,81,103],[82,102,103],[72,75,83,92,103],[84,103],[85,103],[63,86,103],[87,101,103,107],[88,103],[89,103],[75,90,103],[90,91,103,105],[75,92,93,94,103],[92,94,103],[92,93,103],[95,103],[96,103],[75,97,98,103],[97,98,103],[69,83,92,99,103],[100,103],[83,101,103],[64,78,89,102,103],[69,103],[92,103,104],[103,105],[103,106],[64,69,75,77,86,92,102,103,105,107],[92,103,108],[40,103],[40,41,42,43,103],[40,58,103]],"referencedMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[58,13],[57,14],[111,15],[60,16],[61,16],[63,17],[64,18],[65,19],[66,20],[67,21],[68,22],[69,23],[70,24],[71,25],[72,26],[73,26],[74,27],[75,28],[76,29],[77,30],[62,15],[109,15],[78,31],[79,32],[80,33],[110,34],[81,35],[82,36],[83,37],[84,38],[85,39],[86,40],[87,41],[88,42],[89,43],[90,44],[91,45],[92,46],[94,47],[93,48],[95,49],[96,50],[97,51],[98,52],[99,53],[100,54],[101,55],[102,56],[103,57],[104,58],[105,59],[106,60],[107,61],[108,62],[40,15],[8,15],[10,15],[9,15],[2,15],[11,15],[12,15],[13,15],[14,15],[15,15],[16,15],[17,15],[18,15],[3,15],[4,15],[22,15],[19,15],[20,15],[21,15],[23,15],[24,15],[25,15],[5,15],[26,15],[27,15],[28,15],[29,15],[6,15],[30,15],[31,15],[32,15],[33,15],[7,15],[38,15],[34,15],[35,15],[36,15],[37,15],[1,15],[39,15],[41,63],[42,63],[44,64],[59,65],[43,63]],"exportedModulesMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[58,13],[57,14],[111,15],[60,16],[61,16],[63,17],[64,18],[65,19],[66,20],[67,21],[68,22],[69,23],[70,24],[71,25],[72,26],[73,26],[74,27],[75,28],[76,29],[77,30],[62,15],[109,15],[78,31],[79,32],[80,33],[110,34],[81,35],[82,36],[83,37],[84,38],[85,39],[86,40],[87,41],[88,42],[89,43],[90,44],[91,45],[92,46],[94,47],[93,48],[95,49],[96,50],[97,51],[98,52],[99,53],[100,54],[101,55],[102,56],[103,57],[104,58],[105,59],[106,60],[107,61],[108,62],[40,15],[8,15],[10,15],[9,15],[2,15],[11,15],[12,15],[13,15],[14,15],[15,15],[16,15],[17,15],[18,15],[3,15],[4,15],[22,15],[19,15],[20,15],[21,15],[23,15],[24,15],[25,15],[5,15],[26,15],[27,15],[28,15],[29,15],[6,15],[30,15],[31,15],[32,15],[33,15],[7,15],[38,15],[34,15],[35,15],[36,15],[37,15],[1,15],[39,15],[41,63],[42,63],[44,64],[59,65],[43,63]],"semanticDiagnosticsPerFile":[46,47,45,48,49,50,51,52,53,54,55,56,58,57,111,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,62,109,78,79,80,110,81,82,83,84,85,86,87,88,89,90,91,92,94,93,95,96,97,98,99,100,101,102,103,104,105,106,107,108,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,41,42,44,59,43]},"version":"4.5.4"}
1
+ {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../src/context-path.ts","../src/file-drop-helper.ts","../src/fullscreen.ts","../src/sleep.ts","../src/os.ts","../src/swipe-listener.ts","../src/index.ts","../../../node_modules/@types/lodash/common/common.d.ts","../../../node_modules/@types/lodash/common/array.d.ts","../../../node_modules/@types/lodash/common/collection.d.ts","../../../node_modules/@types/lodash/common/date.d.ts","../../../node_modules/@types/lodash/common/function.d.ts","../../../node_modules/@types/lodash/common/lang.d.ts","../../../node_modules/@types/lodash/common/math.d.ts","../../../node_modules/@types/lodash/common/number.d.ts","../../../node_modules/@types/lodash/common/object.d.ts","../../../node_modules/@types/lodash/common/seq.d.ts","../../../node_modules/@types/lodash/common/string.d.ts","../../../node_modules/@types/lodash/common/util.d.ts","../../../node_modules/@types/lodash/index.d.ts","../../../node_modules/@types/lodash/debounce.d.ts","../src/mixins/infinite-scrollable.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/mocha/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","a84f74a36313258ea3bf2fa085568a35530a423035037be03ce67e02c768787f","69ef8de8a4e2551f1a0e21d82a04d233fb5d7d8a1f8db661a1a18e880b4e7545","b18b9acb5cff76a70fec4f1effd260b9f956bba6edb28c1e160979f0b9a51dd6","d9e51838c1aa2a91b7d2a495adb92ab70eb35c81fcd3b359c2509903958bf3f8","6d7c1a6397a03fec38e9c647f0ac42c2179a65f4c7356dcdd4a3cca6ae264d47","d1d0e3e5bd9e070e932c938bd580da6fce3b6a9e230b7156584f7b38ce3a9c4e","871e2c3885751e5ecd252776478a49b9c48527e4224936840ff81feab926c0b2","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","fe4a2042d087990ebfc7dc0142d5aaf5a152e4baea86b45f283f103ec1e871ea","d88a479cccf787b4aa82362150fbeba5211a32dbfafa7b92ba6995ecaf9a1a89","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","ae9930989ed57478eb03b9b80ad3efa7a3eacdfeff0f78ecf7894c4963a64f93","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","6ac6f24aff52e62c3950461aa17eab26e3a156927858e6b654baef0058b4cd1e",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"a5f9563c1315cffbc1e73072d96dcd42332f4eebbdffd7c3e904f545c9e9fe24","1d12501ae0fc9ed02db30f621fb6f82fdf3fea76b0c82300a86ad7b7e61f8a79","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"c2ab70bbc7a24c42a790890739dd8a0ba9d2e15038b40dff8163a97a5d148c00","affectsGlobalScope":true},"422dbb183fdced59425ca072c8bd09efaa77ce4e2ab928ec0d8a1ce062d2a45a",{"version":"2a801b0322994c3dd7f0ef30265d19b3dd3bae6d793596879166ed6219c3da68","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","bcc8caf03ee65fe8610d258752f255fbdddbb2e4de7b6c5628956a5a0d859ec8","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","cc0b61316c4f37393f1f9595e93b673f4184e9d07f4c127165a490ec4a928668","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"c28e5baab1b53377c90d12970e207a2644bc3627840066449e37e2a59125d07e","affectsGlobalScope":true},"7a5459efa09ea82088234e6533a203d528c594b01787fb90fba148885a36e8b6","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","fce6a1a1553ff7d54ffb8bb3ae488c9cb5f2f4f4e52212c1abe40f544819ef35","ad41bb744149e92adb06eb953da195115620a3f2ad48e7d3ae04d10762dae197","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"5d0a9ea09d990b5788f867f1c79d4878f86f7384cb7dab38eecbf22f9efd063d","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","00fa7ce8bc8acc560dc341bbfdf37840a8c59e6a67c9bfa3fa5f36254df35db2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"cfe724f7c694aab65a9bdd1acb05997848c504548c9d4c71645c187a091cfa2a","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"3345c276cab0e76dda86c0fb79104ff915a4580ba0f3e440870e183b1baec476","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","e383ff72aabf294913f8c346f5da1445ae6ad525836d28efd52cbadc01a361a6","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7","1835259a20b9fa6b1882931375b69ae5978195f2b139b4e0db51ec8319261649","b52cd693219a63dd21282ac99a7bf55f77cbe8a91f097968856419cc2e05f017","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"267af67ea520cabd16402522756b19ac63d9e2c1c86e7c4d1ddeb991c32e12c9",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5,"useDefineForClassFields":false},"fileIdsList":[[48,50,51,52,53,54,55,56,57,58,59,60,106],[48,49,51,52,53,54,55,56,57,58,59,60,106],[49,50,51,52,53,54,55,56,57,58,59,60,106],[48,49,50,52,53,54,55,56,57,58,59,60,106],[48,49,50,51,53,54,55,56,57,58,59,60,106],[48,49,50,51,52,54,55,56,57,58,59,60,106],[48,49,50,51,52,53,55,56,57,58,59,60,106],[48,49,50,51,52,53,54,56,57,58,59,60,106],[48,49,50,51,52,53,54,55,57,58,59,60,106],[48,49,50,51,52,53,54,55,56,58,59,60,106],[48,49,50,51,52,53,54,55,56,57,59,60,106],[48,49,50,51,52,53,54,55,56,57,58,60,106],[60,106],[48,49,50,51,52,53,54,55,56,57,58,59,106],[106],[63,106],[66,106],[67,72,106],[68,78,79,86,95,105,106],[68,69,78,86,106],[70,106],[71,72,79,87,106],[72,95,102,106],[73,75,78,86,106],[74,106],[75,76,106],[77,78,106],[78,106],[78,79,80,95,105,106],[78,79,80,95,106],[81,86,95,105,106],[78,79,81,82,86,95,102,105,106],[81,83,95,102,105,106],[63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112],[78,84,106],[85,105,106],[75,78,86,95,106],[87,106],[88,106],[66,89,106],[90,104,106,110],[91,106],[92,106],[78,93,106],[93,94,106,108],[78,95,96,97,106],[95,97,106],[95,96,106],[98,106],[99,106],[78,100,101,106],[100,101,106],[72,86,95,102,106],[103,106],[86,104,106],[67,81,92,105,106],[72,106],[95,106,107],[106,108],[106,109],[67,72,78,80,89,95,105,106,108,110],[95,106,111],[40,106],[40,41,42,43,44,45,46,106],[40,61,106]],"referencedMap":[[49,1],[50,2],[48,3],[51,4],[52,5],[53,6],[54,7],[55,8],[56,9],[57,10],[58,11],[59,12],[61,13],[60,14],[114,15],[63,16],[64,16],[66,17],[67,18],[68,19],[69,20],[70,21],[71,22],[72,23],[73,24],[74,25],[75,26],[76,26],[77,27],[78,28],[79,29],[80,30],[65,15],[112,15],[81,31],[82,32],[83,33],[113,34],[84,35],[85,36],[86,37],[87,38],[88,39],[89,40],[90,41],[91,42],[92,43],[93,44],[94,45],[95,46],[97,47],[96,48],[98,49],[99,50],[100,51],[101,52],[102,53],[103,54],[104,55],[105,56],[106,57],[107,58],[108,59],[109,60],[110,61],[111,62],[40,15],[8,15],[10,15],[9,15],[2,15],[11,15],[12,15],[13,15],[14,15],[15,15],[16,15],[17,15],[18,15],[3,15],[4,15],[22,15],[19,15],[20,15],[21,15],[23,15],[24,15],[25,15],[5,15],[26,15],[27,15],[28,15],[29,15],[6,15],[30,15],[31,15],[32,15],[33,15],[7,15],[38,15],[34,15],[35,15],[36,15],[37,15],[1,15],[39,15],[41,63],[42,63],[43,63],[47,64],[62,65],[45,63],[44,63],[46,63]],"exportedModulesMap":[[49,1],[50,2],[48,3],[51,4],[52,5],[53,6],[54,7],[55,8],[56,9],[57,10],[58,11],[59,12],[61,13],[60,14],[114,15],[63,16],[64,16],[66,17],[67,18],[68,19],[69,20],[70,21],[71,22],[72,23],[73,24],[74,25],[75,26],[76,26],[77,27],[78,28],[79,29],[80,30],[65,15],[112,15],[81,31],[82,32],[83,33],[113,34],[84,35],[85,36],[86,37],[87,38],[88,39],[89,40],[90,41],[91,42],[92,43],[93,44],[94,45],[95,46],[97,47],[96,48],[98,49],[99,50],[100,51],[101,52],[102,53],[103,54],[104,55],[105,56],[106,57],[107,58],[108,59],[109,60],[110,61],[111,62],[40,15],[8,15],[10,15],[9,15],[2,15],[11,15],[12,15],[13,15],[14,15],[15,15],[16,15],[17,15],[18,15],[3,15],[4,15],[22,15],[19,15],[20,15],[21,15],[23,15],[24,15],[25,15],[5,15],[26,15],[27,15],[28,15],[29,15],[6,15],[30,15],[31,15],[32,15],[33,15],[7,15],[38,15],[34,15],[35,15],[36,15],[37,15],[1,15],[39,15],[41,63],[42,63],[43,63],[47,64],[62,65],[45,63],[44,63],[46,63]],"semanticDiagnosticsPerFile":[49,50,48,51,52,53,54,55,56,57,58,59,61,60,114,63,64,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,65,112,81,82,83,113,84,85,86,87,88,89,90,91,92,93,94,95,97,96,98,99,100,101,102,103,104,105,106,107,108,109,110,111,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,41,42,43,47,62,45,44,46]},"version":"4.5.4"}
package/package.json CHANGED
@@ -3,11 +3,17 @@
3
3
  "description": "Webcomponent utils following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "heartyoh",
6
- "version": "0.3.8",
6
+ "version": "0.3.9",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
10
10
  ".": "./dist/src/index.js",
11
+ "./fullscreen.js": "./dist/src/fullscreen.js",
12
+ "./os.js": "./dist/src/os.js",
13
+ "./swipe-listener.js": "./dist/src/swipe-listener.js",
14
+ "./sleep.js": "./dist/src/sleep.js",
15
+ "./file-drop-helper.js": "./dist/src/file-drop-helper.js",
16
+ "./context-path.js": "./dist/src/context-path.js",
11
17
  "./mixins/infinite-scrollable.js": "./dist/src/mixins/infinite-scrollable.js"
12
18
  },
13
19
  "publishConfig": {
@@ -66,5 +72,5 @@
66
72
  "dependencies": {
67
73
  "lodash": "^4.17.21"
68
74
  },
69
- "gitHead": "7d5cd8c985a5b0fcae4bb7237eb771ab13f0c9a9"
75
+ "gitHead": "d63971adcea045ccd788ff4ae5b9e2ca561bb754"
70
76
  }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * 풀스크린 전환 이후와 풀스크린 해제 이후에 호출되는 콜백함수
3
+ * @callback FullscreenCallback
4
+ */
5
+ export type FullscreenCallback = () => void
6
+
7
+ /**
8
+ * 엘리먼트를 풀스크린으로 표시되도록 한다.
9
+ * @param {HTMLElement} element 대상 엘리먼트
10
+ * @param {FullscreenCallback} afterfull 풀스크린이 된 이후에 호출되는 콜백함수
11
+ * @param {FullscreenCallback} afterfinish 풀스크린이 해제된 이후에 호출되는 콜백함수
12
+ */
13
+ export function fullscreen(element: HTMLElement, afterfull?: FullscreenCallback, afterfinish?: FullscreenCallback) {
14
+ var org_width = element.style.width
15
+ var org_height = element.style.height
16
+
17
+ function _fullscreen_callback(e: Event) {
18
+ if (
19
+ !document.fullscreenElement &&
20
+ //@ts-ignore
21
+ !document.mozFullScreen &&
22
+ //@ts-ignore
23
+ !document.webkitIsFullScreen &&
24
+ //@ts-ignore
25
+ !document.msFullscreenElement
26
+ ) {
27
+ ;['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event =>
28
+ document.removeEventListener(event, _fullscreen_callback)
29
+ )
30
+
31
+ element.style.width = org_width
32
+ element.style.height = org_height
33
+
34
+ afterfinish && afterfinish()
35
+ } else {
36
+ element.style.width = '100%'
37
+ element.style.height = '100%'
38
+
39
+ afterfull && afterfull()
40
+ }
41
+ }
42
+
43
+ ;['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'].forEach(event =>
44
+ document.addEventListener(event, _fullscreen_callback)
45
+ )
46
+
47
+ if (element.requestFullscreen) element.requestFullscreen()
48
+ //@ts-ignore
49
+ else if (element.webkitRequestFullScreen) element.webkitRequestFullScreen()
50
+ //@ts-ignore
51
+ else if (element.mozRequestFullScreen) element.mozRequestFullScreen()
52
+ //@ts-ignore
53
+ else if (element.msRequestFullscreen) element.msRequestFullscreen()
54
+ }
55
+
56
+ export function exitfullscreen() {
57
+ if (document.exitFullscreen) document.exitFullscreen()
58
+ //@ts-ignore
59
+ else if (document.mozCancelFullScreen) document.mozCancelFullScreen()
60
+ //@ts-ignore
61
+ else if (document.webkitCancelFullScreen) document.webkitCancelFullScreen()
62
+ //@ts-ignore
63
+ else if (document.msExitFullscreen) document.msExitFullscreen()
64
+ }
65
+
66
+ export function togglefullscreen(
67
+ element: HTMLElement,
68
+ afterfull?: FullscreenCallback,
69
+ afterfinish?: FullscreenCallback
70
+ ) {
71
+ if (
72
+ !document.fullscreenElement &&
73
+ //@ts-ignore
74
+ !document.mozFullScreen &&
75
+ //@ts-ignore
76
+ !document.webkitIsFullScreen &&
77
+ //@ts-ignore
78
+ !document.msFullscreenElement
79
+ )
80
+ fullscreen(element, afterfull, afterfinish)
81
+ else exitfullscreen()
82
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from './sleep.js'
2
2
  export * from './file-drop-helper.js'
3
3
  export * from './context-path.js'
4
+ export * from './os.js'
5
+ export * from './swipe-listener.js'
6
+ export * from './fullscreen.js'
package/src/os.ts ADDED
@@ -0,0 +1,45 @@
1
+ var os = 'Unknown OS'
2
+
3
+ if (navigator.userAgent.indexOf('Win') != -1) os = 'Windows'
4
+ else if (navigator.userAgent.indexOf('Mac') != -1) os = 'Mac'
5
+ else if (navigator.userAgent.indexOf('Linux') != -1) os = 'Linux'
6
+ else if (navigator.userAgent.indexOf('Android') != -1) os = 'Android'
7
+ else if (navigator.userAgent.indexOf('like Mac') != -1) os = 'iOS'
8
+
9
+ var mobile = os === 'iOS' || os === 'Android'
10
+
11
+ /**
12
+ * method to get operating system of running browser
13
+ * @returns {string} name of OS : 'Windows | 'Mac' | 'Android' | 'iOS'
14
+ */
15
+ export function getOS() {
16
+ return os
17
+ }
18
+
19
+ /**
20
+ * method to tell if platform of running browser is kind of mobile device
21
+ * @returns {boolean}
22
+ */
23
+ export function isMobileDevice() {
24
+ return mobile
25
+ }
26
+
27
+ /**
28
+ * method to tell if operating system of running browser is iOS
29
+ * @returns {boolean}
30
+ */
31
+ export function isIOS() {
32
+ return os === 'iOS'
33
+ }
34
+
35
+ /**
36
+ * method to tell if operating system of running browser is MacOS
37
+ * @returns {boolean}
38
+ */
39
+ export function isMacOS() {
40
+ return os === 'Mac'
41
+ }
42
+
43
+ export function isSafari() {
44
+ return !navigator.userAgent.match(/chrome|chromium|crios/i) && navigator.userAgent.match(/safari/i)
45
+ }
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Starts monitoring swipes on the given element and
3
+ * emits `swipe` event when a swipe gesture is performed.
4
+ * @param {DOMElement} element Element on which to listen for swipe gestures.
5
+ * @param {Object} options Optional: Options.
6
+ * @return {Object}
7
+ */
8
+ export function SwipeListener(element: HTMLElement, options?: any) {
9
+ if (!element) return
10
+
11
+ // CustomEvent polyfill
12
+ if (typeof window !== 'undefined') {
13
+ ;(function () {
14
+ if (typeof window.CustomEvent === 'function') return false
15
+ function CustomEvent(event: string, params: any) {
16
+ params = params || { bubbles: false, cancelable: false, detail: undefined }
17
+ var evt = document.createEvent('CustomEvent')
18
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
19
+ return evt
20
+ }
21
+ CustomEvent.prototype = window.Event.prototype
22
+ ;(window as any).CustomEvent = CustomEvent
23
+ })()
24
+ }
25
+
26
+ let defaultOpts = {
27
+ minHorizontal: 10, // Minimum number of pixels traveled to count as a horizontal swipe.
28
+ minVertical: 10, // Minimum number of pixels traveled to count as a vertical swipe.
29
+ deltaHorizontal: 3, // Delta for horizontal swipe
30
+ deltaVertical: 5, // Delta for vertical swipe
31
+ preventScroll: false, // Prevents scrolling when swiping.
32
+ lockAxis: true, // Select only one axis to be true instead of multiple.
33
+ touch: true, // Listen for touch events
34
+ mouse: true // Listen for mouse events
35
+ }
36
+
37
+ // Set options
38
+ if (!options) {
39
+ options = {}
40
+ }
41
+ options = {
42
+ ...defaultOpts,
43
+ ...options
44
+ }
45
+
46
+ // Store the touches
47
+ let touches: Array<{ x: number; y: number }> = []
48
+
49
+ // Not dragging by default.
50
+ let dragging = false
51
+
52
+ // When mouse-click is started, make dragging true.
53
+ const _mousedown = function (e: MouseEvent) {
54
+ dragging = true
55
+ }
56
+
57
+ // When mouse-click is released, make dragging false and signify end by imitating `touchend`.
58
+ const _mouseup = function (e: MouseEvent) {
59
+ dragging = false
60
+ _touchend(e as any)
61
+ }
62
+
63
+ // When mouse is moved while being clicked, imitate a `touchmove`.
64
+ const _mousemove = function (e: MouseEvent) {
65
+ if (dragging) {
66
+ ;(e as any).changedTouches = [
67
+ {
68
+ clientX: e.clientX,
69
+ clientY: e.clientY
70
+ }
71
+ ]
72
+ _touchmove(e as any)
73
+ }
74
+ }
75
+
76
+ if (options.mouse) {
77
+ element.addEventListener('mousedown', _mousedown)
78
+ element.addEventListener('mouseup', _mouseup)
79
+ element.addEventListener('mousemove', _mousemove)
80
+ }
81
+
82
+ // When the swipe is completed, calculate the direction.
83
+ const _touchend = function (e: TouchEvent) {
84
+ if (!touches.length) return
85
+
86
+ const touch = typeof TouchEvent === 'function' && e instanceof TouchEvent
87
+
88
+ let x = [],
89
+ y = []
90
+
91
+ let directions = {
92
+ top: false,
93
+ right: false,
94
+ bottom: false,
95
+ left: false
96
+ }
97
+
98
+ for (let i = 0; i < touches.length; i++) {
99
+ x.push(touches[i].x)
100
+ y.push(touches[i].y)
101
+ }
102
+
103
+ const xs = x[0],
104
+ xe = x[x.length - 1], // Start and end x-coords
105
+ ys = y[0],
106
+ ye = y[y.length - 1] // Start and end y-coords
107
+
108
+ const eventCoords = {
109
+ x: [xs, xe],
110
+ y: [ys, ye]
111
+ }
112
+
113
+ if (touches.length > 1) {
114
+ const swipeReleaseEventData = {
115
+ detail: {
116
+ touch,
117
+ target: e.target,
118
+ ...eventCoords
119
+ }
120
+ }
121
+
122
+ let swipeReleaseEvent = new CustomEvent('swiperelease', swipeReleaseEventData)
123
+ element.dispatchEvent(swipeReleaseEvent)
124
+ }
125
+
126
+ // Determine left or right
127
+ let diff = x[0] - x[x.length - 1]
128
+ let swipe = 'none'
129
+ if (diff > 0) {
130
+ swipe = 'left'
131
+ } else {
132
+ swipe = 'right'
133
+ }
134
+
135
+ let min = Math.min(...x),
136
+ max = Math.max(...x),
137
+ _diff
138
+
139
+ // If minimum horizontal distance was travelled
140
+ if (Math.abs(diff) >= options.minHorizontal) {
141
+ switch (swipe) {
142
+ case 'left':
143
+ _diff = Math.abs(min - x[x.length - 1])
144
+ if (_diff <= options.deltaHorizontal) {
145
+ directions.left = true
146
+ }
147
+ break
148
+ case 'right':
149
+ _diff = Math.abs(max - x[x.length - 1])
150
+ if (_diff <= options.deltaHorizontal) {
151
+ directions.right = true
152
+ }
153
+ break
154
+ }
155
+ }
156
+
157
+ // Determine top or bottom
158
+ diff = y[0] - y[y.length - 1]
159
+ swipe = 'none'
160
+ if (diff > 0) {
161
+ swipe = 'top'
162
+ } else {
163
+ swipe = 'bottom'
164
+ }
165
+
166
+ min = Math.min(...y)
167
+ max = Math.max(...y)
168
+
169
+ // If minimum vertical distance was travelled
170
+ if (Math.abs(diff) >= options.minVertical) {
171
+ switch (swipe) {
172
+ case 'top':
173
+ _diff = Math.abs(min - y[y.length - 1])
174
+ if (_diff <= options.deltaVertical) {
175
+ directions.top = true
176
+ }
177
+ break
178
+ case 'bottom':
179
+ _diff = Math.abs(max - y[y.length - 1])
180
+ if (_diff <= options.deltaVertical) {
181
+ directions.bottom = true
182
+ }
183
+ break
184
+ }
185
+ }
186
+
187
+ // Clear touches array.
188
+ touches = []
189
+
190
+ // If there is a swipe direction, emit an event.
191
+ if (directions.top || directions.right || directions.bottom || directions.left) {
192
+ /**
193
+ * If lockAxis is true, determine which axis to select.
194
+ * The axis with the most travel is selected.
195
+ * TODO: Factor in for the orientation of the device
196
+ * and use it as a weight to determine the travel along an axis.
197
+ */
198
+ if (options.lockAxis) {
199
+ if ((directions.left || directions.right) && Math.abs(xs - xe) > Math.abs(ys - ye)) {
200
+ directions.top = directions.bottom = false
201
+ } else if ((directions.top || directions.bottom) && Math.abs(xs - xe) < Math.abs(ys - ye)) {
202
+ directions.left = directions.right = false
203
+ }
204
+ }
205
+
206
+ const eventData = {
207
+ detail: {
208
+ directions,
209
+ touch,
210
+ target: e.target,
211
+ ...eventCoords
212
+ }
213
+ }
214
+
215
+ let event = new CustomEvent('swipe', eventData)
216
+ element.dispatchEvent(event)
217
+ } else {
218
+ let cancelEvent = new CustomEvent('swipecancel', {
219
+ detail: {
220
+ touch,
221
+ target: e.target,
222
+ ...eventCoords
223
+ }
224
+ })
225
+ element.dispatchEvent(cancelEvent)
226
+ }
227
+ }
228
+
229
+ // When a swipe is performed, store the coords.
230
+ const _touchmove = function (e: TouchEvent) {
231
+ let touch = e.changedTouches[0]
232
+ touches.push({
233
+ x: touch.clientX,
234
+ y: touch.clientY
235
+ })
236
+
237
+ // Emit a `swiping` event if there are more than one touch-points.
238
+ if (touches.length > 1) {
239
+ const xs = touches[0].x, // Start and end x-coords
240
+ xe = touches[touches.length - 1].x,
241
+ ys = touches[0].y, // Start and end y-coords
242
+ ye = touches[touches.length - 1].y,
243
+ eventData = {
244
+ detail: {
245
+ x: [xs, xe],
246
+ y: [ys, ye],
247
+ touch: typeof TouchEvent === 'function' && e instanceof TouchEvent,
248
+ target: e.target
249
+ }
250
+ }
251
+ let event = new CustomEvent('swiping', eventData)
252
+
253
+ const shouldPrevent =
254
+ options.preventScroll === true || (typeof options.preventScroll === 'function' && options.preventScroll(event))
255
+
256
+ if (shouldPrevent) {
257
+ e.preventDefault()
258
+ }
259
+
260
+ element.dispatchEvent(event)
261
+ }
262
+ }
263
+
264
+ // Test via a getter in the options object to see if the passive property is accessed
265
+ let passiveOptions: any = false
266
+ try {
267
+ const testOptions = Object.defineProperty({}, 'passive', {
268
+ get: function () {
269
+ passiveOptions = { passive: !options.preventScroll }
270
+ }
271
+ })
272
+ window.addEventListener('testPassive', null as any, testOptions)
273
+ window.removeEventListener('testPassive', null as any, testOptions)
274
+ } catch (e) {}
275
+
276
+ if (options.touch) {
277
+ element.addEventListener('touchmove', _touchmove, passiveOptions)
278
+ element.addEventListener('touchend', _touchend)
279
+ }
280
+
281
+ return {
282
+ off: function () {
283
+ element.removeEventListener('touchmove', _touchmove, passiveOptions)
284
+ element.removeEventListener('touchend', _touchend)
285
+ element.removeEventListener('mousedown', _mousedown)
286
+ element.removeEventListener('mouseup', _mouseup)
287
+ element.removeEventListener('mousemove', _mousemove)
288
+ }
289
+ }
290
+ }