@ev-core/aurelia-v1-sheet 0.6.5 → 2.0.0
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/dist/commonjs/au-drag.d.ts +1 -30
- package/dist/commonjs/au-drag.js +2 -70
- package/dist/commonjs/au-drag.js.map +1 -1
- package/dist/commonjs/elements/au-sheet-component.css +107 -107
- package/dist/commonjs/elements/au-sheet-component.d.ts +5 -18
- package/dist/commonjs/elements/au-sheet-component.html +26 -26
- package/dist/commonjs/elements/au-sheet-component.js +16 -109
- package/dist/commonjs/elements/au-sheet-component.js.map +1 -1
- package/dist/commonjs/interfaces.d.ts +1 -37
- package/dist/commonjs/options.d.ts +1 -1
- package/dist/commonjs/options.js +2 -8
- package/dist/commonjs/options.js.map +1 -1
- package/dist/native-modules/au-drag.d.ts +1 -30
- package/dist/native-modules/au-drag.js +1 -69
- package/dist/native-modules/au-drag.js.map +1 -1
- package/dist/native-modules/elements/au-sheet-component.css +107 -107
- package/dist/native-modules/elements/au-sheet-component.d.ts +5 -18
- package/dist/native-modules/elements/au-sheet-component.html +26 -26
- package/dist/native-modules/elements/au-sheet-component.js +15 -108
- package/dist/native-modules/elements/au-sheet-component.js.map +1 -1
- package/dist/native-modules/interfaces.d.ts +1 -37
- package/dist/native-modules/options.d.ts +1 -1
- package/dist/native-modules/options.js +2 -8
- package/dist/native-modules/options.js.map +1 -1
- package/package.json +7 -3
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type positionType = 'client' | 'page' | 'screen';
|
|
3
|
-
interface IAuDragConfig {
|
|
4
|
-
positionType: positionType;
|
|
5
|
-
passiveListeners: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class DragEventHandler<T extends object> {
|
|
8
|
-
private readonly element;
|
|
9
|
-
static create<T extends object>(element: Element, config?: IAuDragConfig): DragEventHandler<T>;
|
|
10
|
-
private xKey;
|
|
11
|
-
private yKey;
|
|
12
|
-
private listenerOptions;
|
|
13
|
-
private isDragging;
|
|
14
|
-
startPosition: IPosition;
|
|
15
|
-
private _data;
|
|
16
|
-
getData(): T;
|
|
17
|
-
onStart: (startPosition: IPosition, event: MouseEvent | TouchEvent | Event, data?: T) => T | void;
|
|
18
|
-
onMove: (endPosition: IPosition, startPosition: IPosition, event: MouseEvent | TouchEvent | Event, data?: T) => T | void;
|
|
19
|
-
onEnd: (currentPosition: IPosition, startPosition: IPosition, event: MouseEvent | TouchEvent | Event, data?: T) => T | void;
|
|
20
|
-
setPositionType(type: positionType): void;
|
|
21
|
-
constructor(element: Element, config?: IAuDragConfig);
|
|
22
|
-
private startEvent;
|
|
23
|
-
private dragEvent;
|
|
24
|
-
private endEvent;
|
|
25
|
-
stop(): void;
|
|
26
|
-
private getPosition;
|
|
27
|
-
start(): void;
|
|
28
|
-
dispose(): void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
1
|
+
export { DragEventHandler } from '@ev-core/au-core-sheet';
|
package/dist/commonjs/au-drag.js
CHANGED
|
@@ -1,75 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DragEventHandler = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const endEvents = ['mouseup', 'touchend'];
|
|
7
|
-
class DragEventHandler {
|
|
8
|
-
static create(element, config) { return new DragEventHandler(element, config); }
|
|
9
|
-
getData() { return this._data; }
|
|
10
|
-
setPositionType(type) {
|
|
11
|
-
this.xKey = type + 'X';
|
|
12
|
-
this.yKey = type + 'Y';
|
|
13
|
-
}
|
|
14
|
-
constructor(element, config) {
|
|
15
|
-
this.element = element;
|
|
16
|
-
this.listenerOptions = { passive: true };
|
|
17
|
-
this.isDragging = false;
|
|
18
|
-
this._data = {};
|
|
19
|
-
this.startEvent = (event) => {
|
|
20
|
-
this.isDragging = true;
|
|
21
|
-
const pos = this.getPosition(event);
|
|
22
|
-
this.startPosition = pos;
|
|
23
|
-
const data = this.onStart?.(pos, event, this._data);
|
|
24
|
-
if (data) {
|
|
25
|
-
this._data = data;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
this.dragEvent = (event) => {
|
|
29
|
-
if (this.isDragging) {
|
|
30
|
-
const pos = this.getPosition(event);
|
|
31
|
-
const data = this.onMove?.(pos, this.startPosition, event, this._data);
|
|
32
|
-
if (data) {
|
|
33
|
-
this._data = data;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this.endEvent = (event) => {
|
|
38
|
-
if (this.isDragging) {
|
|
39
|
-
this.isDragging = false;
|
|
40
|
-
const pos = this.getPosition(event);
|
|
41
|
-
const data = this.onEnd?.(pos, this.startPosition, event, this._data);
|
|
42
|
-
if (data) {
|
|
43
|
-
this._data = data;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
if (!config) {
|
|
48
|
-
config = { positionType: 'client', passiveListeners: true };
|
|
49
|
-
}
|
|
50
|
-
this.setPositionType(config.positionType);
|
|
51
|
-
this.listenerOptions.passive = config.passiveListeners;
|
|
52
|
-
}
|
|
53
|
-
stop() { this.isDragging = false; }
|
|
54
|
-
getPosition(event) {
|
|
55
|
-
if ('touches' in event && event.touches.length > 0) {
|
|
56
|
-
return { x: event.touches[0][this.xKey], y: event.touches[0][this.yKey] };
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return { x: event[this.xKey], y: event[this.yKey] };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
start() {
|
|
63
|
-
startEvents.forEach(event => { this.element.addEventListener(event, this.startEvent, this.listenerOptions); });
|
|
64
|
-
moveEvents.forEach(event => { document.addEventListener(event, this.dragEvent, this.listenerOptions); });
|
|
65
|
-
endEvents.forEach(event => { document.addEventListener(event, this.endEvent, this.listenerOptions); });
|
|
66
|
-
}
|
|
67
|
-
dispose() {
|
|
68
|
-
startEvents.forEach(event => { this.element.removeEventListener(event, this.startEvent); });
|
|
69
|
-
moveEvents.forEach(event => { document.removeEventListener(event, this.dragEvent); });
|
|
70
|
-
endEvents.forEach(event => { document.removeEventListener(event, this.endEvent); });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.DragEventHandler = DragEventHandler;
|
|
4
|
+
var au_core_sheet_1 = require("@ev-core/au-core-sheet");
|
|
5
|
+
Object.defineProperty(exports, "DragEventHandler", { enumerable: true, get: function () { return au_core_sheet_1.DragEventHandler; } });
|
|
74
6
|
|
|
75
7
|
//# sourceMappingURL=au-drag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/au-drag.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/au-drag.ts"],"names":[],"mappings":";;;AAAA,wDAA0D;AAAjD,iHAAA,gBAAgB,OAAA","file":"au-drag.js","sourceRoot":"../../src/"}
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
.au-sheet {
|
|
2
|
-
position: fixed;
|
|
3
|
-
top: 0;
|
|
4
|
-
left: 0;
|
|
5
|
-
width: 100dvw;
|
|
6
|
-
height: 100dvh;
|
|
7
|
-
display: flex;
|
|
8
|
-
opacity: 0;
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
align-items: center;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
justify-content: flex-end;
|
|
13
|
-
transition: 0.1s linear;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.au-sheet.show {
|
|
17
|
-
opacity: 1;
|
|
18
|
-
pointer-events: auto;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.au-sheet .au-sheet-overlay {
|
|
23
|
-
position: fixed;
|
|
24
|
-
top: 0;
|
|
25
|
-
left: 0;
|
|
26
|
-
z-index: -1;
|
|
27
|
-
width: 100%;
|
|
28
|
-
height: 100%;
|
|
29
|
-
opacity: 0.2;
|
|
30
|
-
background: #000;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.au-sheet .au-sheet-title {
|
|
34
|
-
padding: 0 12px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.au-sheet .au-sheet-content {
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
background: #fff;
|
|
41
|
-
max-height: 100dvh;
|
|
42
|
-
max-width: 1150px;
|
|
43
|
-
/* padding: 10px; */
|
|
44
|
-
transform: translateY(100%);
|
|
45
|
-
border-radius: 12px 12px 0 0;
|
|
46
|
-
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03);
|
|
47
|
-
transition: 0.3s ease;
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.au-sheet.show .au-sheet-content {
|
|
53
|
-
transform: translateY(0%);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.au-sheet.dragging .au-sheet-content {
|
|
57
|
-
transition: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.au-sheet.fullscreen .au-sheet-content {
|
|
61
|
-
border-radius: 0;
|
|
62
|
-
overflow-y: hidden;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.au-sheet .au-sheet-content {
|
|
66
|
-
display: flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.au-sheet-content .au-sheet-draghandle {
|
|
71
|
-
cursor: grab;
|
|
72
|
-
user-select: none;
|
|
73
|
-
padding: 12px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.au-sheet-draghandle span {
|
|
77
|
-
margin: 0 auto;
|
|
78
|
-
height: 4px;
|
|
79
|
-
width: 40px;
|
|
80
|
-
display: block;
|
|
81
|
-
background: #C7D0E1;
|
|
82
|
-
border-radius: 50px;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.au-sheet-content .au-sheet-body {
|
|
86
|
-
height: 100%;
|
|
87
|
-
overflow-y: auto;
|
|
88
|
-
padding: 0 12px 12px 12px;
|
|
89
|
-
scrollbar-width: none;
|
|
90
|
-
overscroll-behavior: contain;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.au-sheet-content .au-sheet-body::-webkit-scrollbar {
|
|
94
|
-
width: 0;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.au-sheet-content .au-sheet-footer {
|
|
98
|
-
padding: 10px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/* .au-sheet-content .au-sheet-body h2 {
|
|
102
|
-
font-size: 1.8rem;
|
|
103
|
-
}
|
|
104
|
-
.au-sheet-content .au-sheet-body p {
|
|
105
|
-
margin-top: 20px;
|
|
106
|
-
font-size: 1.05rem;
|
|
107
|
-
} */
|
|
1
|
+
.au-sheet {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100dvw;
|
|
6
|
+
height: 100dvh;
|
|
7
|
+
display: flex;
|
|
8
|
+
opacity: 0;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
align-items: center;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
justify-content: flex-end;
|
|
13
|
+
transition: 0.1s linear;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.au-sheet.show {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
pointer-events: auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
.au-sheet .au-sheet-overlay {
|
|
23
|
+
position: fixed;
|
|
24
|
+
top: 0;
|
|
25
|
+
left: 0;
|
|
26
|
+
z-index: -1;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
opacity: 0.2;
|
|
30
|
+
background: #000;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.au-sheet .au-sheet-title {
|
|
34
|
+
padding: 0 12px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.au-sheet .au-sheet-content {
|
|
38
|
+
width: 100%;
|
|
39
|
+
position: relative;
|
|
40
|
+
background: #fff;
|
|
41
|
+
max-height: 100dvh;
|
|
42
|
+
max-width: 1150px;
|
|
43
|
+
/* padding: 10px; */
|
|
44
|
+
transform: translateY(100%);
|
|
45
|
+
border-radius: 12px 12px 0 0;
|
|
46
|
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03);
|
|
47
|
+
transition: 0.3s ease;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.au-sheet.show .au-sheet-content {
|
|
53
|
+
transform: translateY(0%);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.au-sheet.dragging .au-sheet-content {
|
|
57
|
+
transition: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.au-sheet.fullscreen .au-sheet-content {
|
|
61
|
+
border-radius: 0;
|
|
62
|
+
overflow-y: hidden;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.au-sheet .au-sheet-content {
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.au-sheet-content .au-sheet-draghandle {
|
|
71
|
+
cursor: grab;
|
|
72
|
+
user-select: none;
|
|
73
|
+
padding: 12px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.au-sheet-draghandle span {
|
|
77
|
+
margin: 0 auto;
|
|
78
|
+
height: 4px;
|
|
79
|
+
width: 40px;
|
|
80
|
+
display: block;
|
|
81
|
+
background: #C7D0E1;
|
|
82
|
+
border-radius: 50px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.au-sheet-content .au-sheet-body {
|
|
86
|
+
height: 100%;
|
|
87
|
+
overflow-y: auto;
|
|
88
|
+
padding: 0 12px 12px 12px;
|
|
89
|
+
scrollbar-width: none;
|
|
90
|
+
overscroll-behavior: contain;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.au-sheet-content .au-sheet-body::-webkit-scrollbar {
|
|
94
|
+
width: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.au-sheet-content .au-sheet-footer {
|
|
98
|
+
padding: 10px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* .au-sheet-content .au-sheet-body h2 {
|
|
102
|
+
font-size: 1.8rem;
|
|
103
|
+
}
|
|
104
|
+
.au-sheet-content .au-sheet-body p {
|
|
105
|
+
margin-top: 20px;
|
|
106
|
+
font-size: 1.05rem;
|
|
107
|
+
} */
|
|
108
108
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type IAuSheetOptions, type IStep, type Placement } from '@ev-core/au-core-sheet';
|
|
2
2
|
import './au-sheet-component.css';
|
|
3
3
|
export declare class AuSheetComponent {
|
|
4
|
-
|
|
4
|
+
private readonly host;
|
|
5
5
|
options: IAuSheetOptions;
|
|
6
6
|
title: string;
|
|
7
7
|
placement: Placement;
|
|
@@ -15,19 +15,17 @@ export declare class AuSheetComponent {
|
|
|
15
15
|
beforeOpen: (sheet: AuSheetComponent) => boolean | void | Promise<boolean | void>;
|
|
16
16
|
afterOpen: (sheet: AuSheetComponent) => void;
|
|
17
17
|
steps: IStep[];
|
|
18
|
-
private currentStep;
|
|
19
|
-
private template;
|
|
20
18
|
private bodyHandler;
|
|
21
19
|
private dragHandler;
|
|
22
|
-
private pushElement;
|
|
23
20
|
private readonly sheetElement;
|
|
24
21
|
private readonly overlayElement;
|
|
25
22
|
private readonly contentElement;
|
|
26
23
|
private readonly dragHandleElement;
|
|
27
24
|
private readonly bodyElement;
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
pusher: ResizeObserver;
|
|
26
|
+
iosWorkaround: () => void;
|
|
30
27
|
initialPad: Partial<CSSStyleDeclaration>;
|
|
28
|
+
constructor();
|
|
31
29
|
attachPadToElement(): void;
|
|
32
30
|
detachPadToElement(): void;
|
|
33
31
|
bind(context: any): void;
|
|
@@ -39,17 +37,6 @@ export declare class AuSheetComponent {
|
|
|
39
37
|
open(): Promise<void>;
|
|
40
38
|
private startListening;
|
|
41
39
|
private stopListening;
|
|
42
|
-
pusher: ResizeObserver;
|
|
43
|
-
iosWorkaround: () => void;
|
|
44
40
|
private setupBodyHandler;
|
|
45
41
|
private setupDragHandler;
|
|
46
|
-
findStep(direction: Direction): IStep;
|
|
47
|
-
findDirection(position: IPosition, startPosition: IPosition): Direction;
|
|
48
|
-
private findRelativePosition;
|
|
49
|
-
private calculate;
|
|
50
|
-
private update;
|
|
51
|
-
findClosestStep(size: Partial<ISize>): IStep;
|
|
52
|
-
findPrevStep(): IStep;
|
|
53
|
-
findNextStep(): IStep;
|
|
54
|
-
snap(step: IStep): void;
|
|
55
42
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="au-sheet"
|
|
3
|
-
ref="sheetElement">
|
|
4
|
-
<div class="au-sheet-overlay"
|
|
5
|
-
ref="overlayElement"
|
|
6
|
-
click.trigger="overlayClick()"></div>
|
|
7
|
-
<div class="au-sheet-content"
|
|
8
|
-
ref="contentElement"
|
|
9
|
-
css.bind="css">
|
|
10
|
-
<div if.bind="showDragHandle"
|
|
11
|
-
class="au-sheet-draghandle"
|
|
12
|
-
ref="dragHandleElement">
|
|
13
|
-
<span></span>
|
|
14
|
-
</div>
|
|
15
|
-
<div if.bind="title" class="au-sheet-title">${title}</div>
|
|
16
|
-
<div class="au-sheet-body slim-scroll" ref="bodyElement">
|
|
17
|
-
<slot></slot>
|
|
18
|
-
</div>
|
|
19
|
-
<div show.bind="showFooter"
|
|
20
|
-
class="au-sheet-footer">
|
|
21
|
-
<slot name="footer"></slot>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
</template>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="au-sheet"
|
|
3
|
+
ref="sheetElement">
|
|
4
|
+
<div class="au-sheet-overlay"
|
|
5
|
+
ref="overlayElement"
|
|
6
|
+
click.trigger="overlayClick()"></div>
|
|
7
|
+
<div class="au-sheet-content"
|
|
8
|
+
ref="contentElement"
|
|
9
|
+
css.bind="css">
|
|
10
|
+
<div if.bind="showDragHandle"
|
|
11
|
+
class="au-sheet-draghandle"
|
|
12
|
+
ref="dragHandleElement">
|
|
13
|
+
<span></span>
|
|
14
|
+
</div>
|
|
15
|
+
<div if.bind="title" class="au-sheet-title">${title}</div>
|
|
16
|
+
<div class="au-sheet-body slim-scroll" ref="bodyElement">
|
|
17
|
+
<slot></slot>
|
|
18
|
+
</div>
|
|
19
|
+
<div show.bind="showFooter"
|
|
20
|
+
class="au-sheet-footer">
|
|
21
|
+
<slot name="footer"></slot>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
</template>
|
|
27
27
|
|
|
@@ -3,21 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AuSheetComponent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const aurelia_framework_1 = require("aurelia-framework");
|
|
6
|
-
const
|
|
6
|
+
const au_core_sheet_1 = require("@ev-core/au-core-sheet");
|
|
7
7
|
const options_1 = require("../options");
|
|
8
8
|
require("./au-sheet-component.css");
|
|
9
|
-
const steps = [
|
|
10
|
-
{ minDim: 200, dim: 40, dynamic: true },
|
|
11
|
-
{ minDim: 200, dim: 100 }
|
|
12
|
-
];
|
|
13
9
|
let AuSheetComponent = class AuSheetComponent {
|
|
14
10
|
constructor() {
|
|
11
|
+
this.host = new au_core_sheet_1.SheetHost();
|
|
15
12
|
this.isOpen = false;
|
|
16
|
-
this.steps =
|
|
13
|
+
this.steps = au_core_sheet_1.defaultSteps;
|
|
17
14
|
this.iosWorkaround = () => {
|
|
18
|
-
|
|
19
|
-
console.log("instan apple");
|
|
20
|
-
console.log(vv);
|
|
15
|
+
aurelia_framework_1.PLATFORM.global.visualViewport;
|
|
21
16
|
};
|
|
22
17
|
this.pusher = new aurelia_framework_1.PLATFORM.global.ResizeObserver(() => {
|
|
23
18
|
this.attachPadToElement();
|
|
@@ -54,7 +49,7 @@ let AuSheetComponent = class AuSheetComponent {
|
|
|
54
49
|
}
|
|
55
50
|
attached() {
|
|
56
51
|
const step = this.steps[0];
|
|
57
|
-
this.snap(step);
|
|
52
|
+
this.host.snap(this.contentElement, this.placement, step);
|
|
58
53
|
this.setupDragHandler();
|
|
59
54
|
this.setupBodyHandler();
|
|
60
55
|
this.sheetElement.style.zIndex = `${this.zIndex}`;
|
|
@@ -110,7 +105,7 @@ let AuSheetComponent = class AuSheetComponent {
|
|
|
110
105
|
if (!element) {
|
|
111
106
|
return;
|
|
112
107
|
}
|
|
113
|
-
const handler =
|
|
108
|
+
const handler = au_core_sheet_1.DragEventHandler.create(element, { positionType: 'client', passiveListeners: false });
|
|
114
109
|
handler.onStart = (start, event, data) => {
|
|
115
110
|
const scrollTopLog = [element.scrollTop];
|
|
116
111
|
const positionLog = [];
|
|
@@ -142,7 +137,7 @@ let AuSheetComponent = class AuSheetComponent {
|
|
|
142
137
|
const lastPosition = data.positionLog[data.positionLog.length - 1];
|
|
143
138
|
const posDelta = firstPosition.y - lastPosition.y;
|
|
144
139
|
const direction = posDelta > 0 ? 'expand' : 'shrink';
|
|
145
|
-
const step = this.findStep(direction);
|
|
140
|
+
const step = this.host.findStep(this.steps, direction);
|
|
146
141
|
if (element.scrollTop < 0) {
|
|
147
142
|
element.scrollTop = 0;
|
|
148
143
|
}
|
|
@@ -150,7 +145,7 @@ let AuSheetComponent = class AuSheetComponent {
|
|
|
150
145
|
element.scrollTop = element.clientHeight;
|
|
151
146
|
}
|
|
152
147
|
if (step) {
|
|
153
|
-
this.snap(step);
|
|
148
|
+
this.host.snap(this.contentElement, this.placement, step);
|
|
154
149
|
}
|
|
155
150
|
};
|
|
156
151
|
this.bodyHandler = handler;
|
|
@@ -159,115 +154,28 @@ let AuSheetComponent = class AuSheetComponent {
|
|
|
159
154
|
if (!this.dragHandleElement) {
|
|
160
155
|
return;
|
|
161
156
|
}
|
|
162
|
-
const handler =
|
|
157
|
+
const handler = au_core_sheet_1.DragEventHandler.create(this.dragHandleElement, { positionType: 'client', passiveListeners: false });
|
|
163
158
|
handler.onStart = (position, event) => {
|
|
164
|
-
const handle = this.findRelativePosition(this.dragHandleElement);
|
|
159
|
+
const handle = this.host.findRelativePosition(this.dragHandleElement);
|
|
165
160
|
this.sheetElement.classList.add("dragging");
|
|
166
161
|
return { handle };
|
|
167
162
|
};
|
|
168
163
|
handler.onMove = (position, startPosition, event, data) => {
|
|
169
164
|
event.preventDefault();
|
|
170
|
-
const size = this.calculate(position, startPosition, data);
|
|
171
|
-
this.update(size);
|
|
165
|
+
const size = this.host.calculate(this.placement, position, startPosition, data);
|
|
166
|
+
this.host.update(this.contentElement, this.placement, size);
|
|
172
167
|
};
|
|
173
168
|
handler.onEnd = (position, startPosition, data) => {
|
|
174
169
|
this.sheetElement.classList.remove("dragging");
|
|
175
|
-
const direction = this.findDirection(position, startPosition);
|
|
176
|
-
let step = this.findStep(direction);
|
|
170
|
+
const direction = this.host.findDirection(this.placement, position, startPosition);
|
|
171
|
+
let step = this.host.findStep(this.steps, direction);
|
|
177
172
|
if (!step) {
|
|
178
|
-
step = this.findClosestStep(this.currentSize);
|
|
173
|
+
step = this.host.findClosestStep(this.steps, this.placement, this.host.currentSize);
|
|
179
174
|
}
|
|
180
|
-
this.snap(step);
|
|
175
|
+
this.host.snap(this.contentElement, this.placement, step);
|
|
181
176
|
};
|
|
182
177
|
this.dragHandler = handler;
|
|
183
178
|
}
|
|
184
|
-
findStep(direction) {
|
|
185
|
-
return direction === 'expand' ? this.findNextStep() : this.findPrevStep();
|
|
186
|
-
}
|
|
187
|
-
findDirection(position, startPosition) {
|
|
188
|
-
let direction;
|
|
189
|
-
switch (this.placement) {
|
|
190
|
-
case 'top':
|
|
191
|
-
break;
|
|
192
|
-
case 'right':
|
|
193
|
-
break;
|
|
194
|
-
case 'bottom':
|
|
195
|
-
direction = position.y > startPosition.y ? 'shrink' : 'expand';
|
|
196
|
-
break;
|
|
197
|
-
case 'left':
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
return direction;
|
|
201
|
-
}
|
|
202
|
-
findRelativePosition(el) {
|
|
203
|
-
const dims = { h: 0, w: 0 };
|
|
204
|
-
if (el) {
|
|
205
|
-
dims.h = el.clientHeight + el.offsetTop;
|
|
206
|
-
dims.w = el.clientWidth + el.offsetLeft;
|
|
207
|
-
}
|
|
208
|
-
return dims;
|
|
209
|
-
}
|
|
210
|
-
calculate(current, start, data) {
|
|
211
|
-
const size = {};
|
|
212
|
-
if (this.placement == 'bottom') {
|
|
213
|
-
const innerHeight = window.innerHeight;
|
|
214
|
-
const handle = ((data?.handle?.h ?? 0) / 2) / innerHeight;
|
|
215
|
-
const delta = start.y - current.y;
|
|
216
|
-
const moveHeight = (delta / innerHeight) - handle;
|
|
217
|
-
const startHeight = 1 - (start.y / innerHeight);
|
|
218
|
-
size.h = (startHeight + moveHeight) * 100;
|
|
219
|
-
}
|
|
220
|
-
return size;
|
|
221
|
-
}
|
|
222
|
-
update(size, snap = false) {
|
|
223
|
-
switch (this.placement) {
|
|
224
|
-
case 'top':
|
|
225
|
-
case 'bottom':
|
|
226
|
-
this.contentElement.style.height = `${size.h}dvh`;
|
|
227
|
-
break;
|
|
228
|
-
case 'right':
|
|
229
|
-
case 'left':
|
|
230
|
-
this.contentElement.style.width = `${size.w}dvw`;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
this.currentSize = size;
|
|
234
|
-
}
|
|
235
|
-
findClosestStep(size) {
|
|
236
|
-
const dim = (this.placement === 'top' || this.placement === 'bottom') ? size.h : size.w;
|
|
237
|
-
return this.steps.reduce((prev, curr) => Math.abs(curr.dim - dim) < Math.abs(prev.dim - dim) ? curr : prev);
|
|
238
|
-
}
|
|
239
|
-
findPrevStep() {
|
|
240
|
-
let step;
|
|
241
|
-
const index = this.steps.indexOf(this.currentStep);
|
|
242
|
-
if (index > 0) {
|
|
243
|
-
step = this.steps[index - 1];
|
|
244
|
-
}
|
|
245
|
-
return step;
|
|
246
|
-
}
|
|
247
|
-
findNextStep() {
|
|
248
|
-
let step;
|
|
249
|
-
const index = this.steps.indexOf(this.currentStep);
|
|
250
|
-
if (index < this.steps.length - 1) {
|
|
251
|
-
step = this.steps[index + 1];
|
|
252
|
-
}
|
|
253
|
-
return step;
|
|
254
|
-
}
|
|
255
|
-
snap(step) {
|
|
256
|
-
switch (this.placement) {
|
|
257
|
-
case 'top':
|
|
258
|
-
case 'bottom':
|
|
259
|
-
console.log("dynamic: " + step.dynamic);
|
|
260
|
-
this.contentElement.style.minHeight = step.minDim ? `${step.minDim}px` : '';
|
|
261
|
-
this.contentElement.style.height = step.dynamic ? '' : `${step.dim}dvh`;
|
|
262
|
-
break;
|
|
263
|
-
case 'right':
|
|
264
|
-
case 'left':
|
|
265
|
-
this.contentElement.style.minWidth = step.minDim ? `${step.minDim}px` : '';
|
|
266
|
-
this.contentElement.style.width = `${step.dim}dvw`;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
this.currentStep = step;
|
|
270
|
-
}
|
|
271
179
|
};
|
|
272
180
|
exports.AuSheetComponent = AuSheetComponent;
|
|
273
181
|
tslib_1.__decorate([
|
|
@@ -323,7 +231,6 @@ tslib_1.__decorate([
|
|
|
323
231
|
tslib_1.__metadata("design:type", Object)
|
|
324
232
|
], AuSheetComponent.prototype, "steps", void 0);
|
|
325
233
|
exports.AuSheetComponent = AuSheetComponent = tslib_1.__decorate([
|
|
326
|
-
(0, aurelia_framework_1.inject)(aurelia_framework_1.DOM.Element),
|
|
327
234
|
(0, aurelia_framework_1.customElement)('au-sheet'),
|
|
328
235
|
tslib_1.__metadata("design:paramtypes", [])
|
|
329
236
|
], AuSheetComponent);
|