@inizioevoke/astro-core 1.7.0 → 2.0.1
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/package.json +3 -5
- package/src/components/FlipCard/FlipCard.ts +15 -9
- package/src/components/ISI/{RightISI.astro → Right/RightISI.astro} +16 -9
- package/src/components/ISI/Right/RightISI.css +61 -0
- package/src/components/ISI/{RightISI.md → Right/RightISI.md} +0 -1
- package/src/components/ISI/Right/RightISI.ts +78 -0
- package/src/components/ISI/Right/index.ts +1 -0
- package/src/components/ISI/index.ts +5 -0
- package/src/components/Modal/Modal.astro +11 -5
- package/src/components/Modal/Modal.css +49 -39
- package/src/components/Modal/Modal.ts +186 -169
- package/src/components/PdfViewer/PdfViewer.astro +26 -12
- package/src/components/PdfViewer/PdfViewer.css +62 -53
- package/src/components/PdfViewer/PdfViewer.ts +446 -210
- package/src/components/ScrollContainer/ScrollContainer.astro +28 -24
- package/src/components/ScrollContainer/ScrollContainer.css +66 -21
- package/src/components/ScrollContainer/ScrollContainer.ts +170 -67
- package/src/components/index.ts +1 -0
- package/src/lib/index.ts +2 -0
- package/src/components/ISI/RightISI.css +0 -31
- package/src/components/ISI/RightISI.ts +0 -27
- package/src/components/Modal/v2/Modal.astro +0 -42
- package/src/components/Modal/v2/Modal.css +0 -155
- package/src/components/Modal/v2/Modal.ts +0 -219
- package/src/components/Modal/v2/ModalOverlay.astro +0 -14
- package/src/components/Modal/v2/ModalTrigger.astro +0 -29
- package/src/components/Modal/v2/index.ts +0 -1
- package/src/components/ScrollContainer/archive-20260417.ts +0 -150
- package/src/components/v2.ts +0 -3
- package/src/lib/v2.ts +0 -1
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
import type { Scrolling } from './ScrollContainer';
|
|
3
4
|
import './ScrollContainer.css';
|
|
4
5
|
|
|
5
6
|
export interface Props extends HTMLAttributes<'div'> {
|
|
6
|
-
|
|
7
|
-
innerWidth?: string | number;
|
|
7
|
+
width?: string | number;
|
|
8
8
|
height?: string | number;
|
|
9
|
-
|
|
10
|
-
horizontal?: boolean;
|
|
9
|
+
scrolling?: Scrolling;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
const {
|
|
14
|
-
|
|
15
|
-
innerWidth,
|
|
13
|
+
width,
|
|
16
14
|
height,
|
|
17
|
-
|
|
18
|
-
horizontal = false,
|
|
15
|
+
scrolling = 'vertical',
|
|
19
16
|
...rest
|
|
20
17
|
} = Astro.props;
|
|
21
18
|
|
|
22
|
-
const containerAttrs = {...rest};
|
|
23
|
-
const
|
|
24
|
-
['class']
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const containerAttrs = {...rest, 'data-scrolling': scrolling};
|
|
20
|
+
const cssClassList = ['evo-scroll-container', containerAttrs['class']];
|
|
21
|
+
delete containerAttrs['class'];
|
|
22
|
+
|
|
23
|
+
switch (scrolling) {
|
|
24
|
+
case 'horizontal':
|
|
25
|
+
cssClassList.push('evo-scroll-horz');
|
|
26
|
+
break;
|
|
27
|
+
case 'vertical':
|
|
28
|
+
cssClassList.push('evo-scroll-vert')
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
cssClassList.push('evo-scroll-both')
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
containerAttrs.style = typeof containerAttrs.style == 'string' ? `${containerAttrs.style}${containerAttrs.style.endsWith(';') ? '' : ';'}` : '';
|
|
29
|
-
if (
|
|
30
|
-
containerAttrs.style = `${containerAttrs.style}width:${typeof
|
|
36
|
+
if (width) {
|
|
37
|
+
containerAttrs.style = `${containerAttrs.style}width:${typeof width == 'number' || /^\d+$/.test(width) ? `${width}px` : width};`;
|
|
31
38
|
}
|
|
32
39
|
if (height) {
|
|
33
40
|
containerAttrs.style = `${containerAttrs.style}height:${typeof height == 'number' || /^\d+$/.test(height) ? `${height}px` : height};`;
|
|
34
41
|
}
|
|
35
|
-
|
|
36
|
-
const contentAttrs: Record<string, string> = {};
|
|
37
|
-
if (innerWidth) {
|
|
38
|
-
contentAttrs.style = `width:${typeof innerWidth == 'number' || /^\d+$/.test(innerWidth) ? `${innerWidth}px` : innerWidth};`
|
|
39
|
-
}
|
|
40
42
|
---
|
|
41
|
-
<evo-scroll-container class:list={
|
|
42
|
-
<div class="evo-scroll-content"
|
|
43
|
+
<evo-scroll-container class:list={cssClassList} {...containerAttrs}>
|
|
44
|
+
<div class="evo-scroll-content">
|
|
43
45
|
<slot />
|
|
44
46
|
</div>
|
|
45
|
-
{
|
|
47
|
+
{scrolling !== 'horizontal' &&
|
|
48
|
+
<div class="evo-scroll-track evo-scroll-track-vert">
|
|
46
49
|
<div class="evo-scroll-thumb"></div>
|
|
47
50
|
</div>}
|
|
48
|
-
{
|
|
51
|
+
{scrolling !== 'vertical' &&
|
|
52
|
+
<div class="evo-scroll-track evo-scroll-track-horz">
|
|
49
53
|
<div class="evo-scroll-thumb"></div>
|
|
50
54
|
</div>}
|
|
51
55
|
</evo-scroll-container>
|
|
@@ -1,68 +1,113 @@
|
|
|
1
1
|
@layer inizioevoke-astro-components {
|
|
2
2
|
:root {
|
|
3
|
-
--evo-scroll-container-border-radius: 4px;
|
|
4
3
|
--evo-scroll-container-track-width: 8px;
|
|
5
|
-
--evo-scroll-container-
|
|
6
|
-
--evo-scroll-container-
|
|
7
|
-
--evo-scroll-container-
|
|
4
|
+
--evo-scroll-container-width-offset: var(--evo-scroll-container-track-width);
|
|
5
|
+
--evo-scroll-container-height-offset: var(--evo-scroll-container-track-width);
|
|
6
|
+
--evo-scroll-container-border-radius: calc(var(--evo-scroll-container-track-width) / 2);
|
|
7
|
+
--evo-scroll-container-track-vert-top: 0px;
|
|
8
|
+
--evo-scroll-container-track-vert-bottom: 0px;
|
|
9
|
+
--evo-scroll-container-track-vert-right: 0px;
|
|
10
|
+
--evo-scroll-container-track-horz-bottom: 0px;
|
|
11
|
+
--evo-scroll-container-track-horz-left: 0px;
|
|
12
|
+
--evo-scroll-container-track-horz-right: 0px;
|
|
13
|
+
/* --evo-scroll-container-track-padding: calc(1rem + var(--evo-scroll-container-track-width)); */
|
|
8
14
|
--evo-scroll-container-track-color: #dddddd;
|
|
9
15
|
--evo-scroll-container-thumb-color: #666666;
|
|
10
16
|
--evo-scroll-container-thumb-border-width: 0px;
|
|
11
17
|
--evo-scroll-container-thumb-border-color: var(--evo-scroll-container-track-color);
|
|
12
|
-
--evo-scroll-container-content-padding-right: calc(1rem + var(--evo-scroll-container-track-width));
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
evo-scroll-container,
|
|
16
21
|
.evo-scroll-container {
|
|
22
|
+
--evo-scroll-container-scrollbar-offset: 0px;
|
|
17
23
|
position: relative;
|
|
18
24
|
display: block;
|
|
19
25
|
width: 100%;
|
|
20
26
|
height: 100%;
|
|
21
27
|
overflow: hidden;
|
|
22
28
|
box-sizing: border-box;
|
|
29
|
+
|
|
30
|
+
&.evo-scroll-both {
|
|
31
|
+
--evo-scroll-container-scrollbar-offset: var(--evo-scroll-container-track-width);
|
|
32
|
+
}
|
|
23
33
|
|
|
24
34
|
* {
|
|
25
35
|
box-sizing: border-box;
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
.evo-scroll-content {
|
|
29
|
-
height: 100%;
|
|
30
|
-
overflow-y: scroll;
|
|
31
|
-
padding-right: var(--evo-scroll-container-content-padding-right);
|
|
32
39
|
-ms-overflow-style: none;
|
|
33
40
|
scrollbar-width: none;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
width: 90%;
|
|
34
43
|
&::-webkit-scrollbar {
|
|
35
44
|
display: none;
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
*:first-child {
|
|
39
|
-
margin-top: 0 !important;
|
|
40
|
-
}
|
|
41
|
-
*:last-child {
|
|
42
|
-
margin-bottom: 0 !important;
|
|
43
|
-
}
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
.evo-scroll-track {
|
|
47
49
|
position: absolute;
|
|
48
|
-
top: var(--evo-scroll-container-track-top);
|
|
49
|
-
right: var(--evo-scroll-container-track-right);
|
|
50
|
-
width: var(--evo-scroll-container-track-width);
|
|
51
|
-
height: calc(100% - var(--evo-scroll-container-track-top) - var(--evo-scroll-container-track-bottom));
|
|
52
50
|
background: var(--evo-scroll-container-track-color);
|
|
53
51
|
border-radius: var(--evo-scroll-container-border-radius);
|
|
54
52
|
|
|
55
53
|
.evo-scroll-thumb {
|
|
56
54
|
box-sizing: border-box;
|
|
57
55
|
position: absolute;
|
|
58
|
-
width: 100%;
|
|
59
56
|
background-color: var(--evo-scroll-container-thumb-color);
|
|
60
57
|
border: var(--evo-scroll-container-thumb-border-width) solid var(--evo-scroll-container-thumb-border-color);
|
|
61
58
|
border-radius: var(--evo-scroll-container-border-radius);
|
|
62
|
-
height: 50px;
|
|
63
59
|
cursor: grab;
|
|
64
60
|
font-size: 0;
|
|
65
61
|
}
|
|
62
|
+
|
|
63
|
+
&.evo-scroll-track-vert {
|
|
64
|
+
top: var(--evo-scroll-container-track-vert-top);
|
|
65
|
+
right: var(--evo-scroll-container-track-vert-right);
|
|
66
|
+
width: var(--evo-scroll-container-track-width);
|
|
67
|
+
height: calc(100% - var(--evo-scroll-container-track-vert-top) - var(--evo-scroll-container-track-vert-bottom) - var(--evo-scroll-container-scrollbar-offset));
|
|
68
|
+
|
|
69
|
+
.evo-scroll-thumb {
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: 50px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
&.evo-scroll-track-horz {
|
|
75
|
+
left: var(--evo-scroll-container-track-horz-left);
|
|
76
|
+
bottom: var(--evo-scroll-container-track-horz-bottom);
|
|
77
|
+
width: calc(100% - var(--evo-scroll-container-track-horz-left) - var(--evo-scroll-container-track-horz-right) - var(--evo-scroll-container-scrollbar-offset));
|
|
78
|
+
height: var(--evo-scroll-container-track-width);
|
|
79
|
+
|
|
80
|
+
.evo-scroll-thumb {
|
|
81
|
+
width: 50px;
|
|
82
|
+
height: 100%;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&.evo-scroll-horz,
|
|
88
|
+
&.evo-scroll-both {
|
|
89
|
+
.evo-scroll-content {
|
|
90
|
+
height: calc(100% - var(--evo-scroll-container-track-width) - var(--evo-scroll-container-track-horz-bottom) - var(--evo-scroll-container-height-offset));
|
|
91
|
+
overflow-x: scroll;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
&.evo-scroll-horz {
|
|
95
|
+
.evo-scroll-content {
|
|
96
|
+
width: 100%;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&.evo-scroll-vert,
|
|
101
|
+
&.evo-scroll-both {
|
|
102
|
+
.evo-scroll-content {
|
|
103
|
+
width: calc(100% - var(--evo-scroll-container-track-width) - var(--evo-scroll-container-track-vert-right) - var(--evo-scroll-container-width-offset));
|
|
104
|
+
overflow-y: scroll;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
&.evo-scroll-vert {
|
|
108
|
+
.evo-scroll-content {
|
|
109
|
+
height: 100%;
|
|
110
|
+
}
|
|
66
111
|
}
|
|
67
112
|
}
|
|
68
113
|
}
|
|
@@ -24,22 +24,49 @@ const mutationObserver = new MutationObserver((mutations) => {
|
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
export type Scrolling = 'horizontal' | 'vertical' | 'both';
|
|
27
28
|
|
|
28
|
-
export
|
|
29
|
+
export interface IEvoScrollContainerElement {
|
|
30
|
+
content: HTMLElement;
|
|
31
|
+
scrollLeft: number;
|
|
32
|
+
scrollTop: number;
|
|
33
|
+
scrollWidth: number;
|
|
34
|
+
scrollHeight: number;
|
|
35
|
+
configureScrollbar: (settings: ScrollbarSettings) => void;
|
|
36
|
+
getScroll: () => { left: number, top: number };
|
|
37
|
+
resize: (opts: { height?: number }) => void;
|
|
38
|
+
resetScrollbar: () => void;
|
|
39
|
+
refresh: () => void;
|
|
40
|
+
scroll(opts?: ScrollToOptions): void;
|
|
41
|
+
scroll(x: number, y: number): void;
|
|
42
|
+
scrollTo(opts?: ScrollToOptions): void;
|
|
43
|
+
scrollTo(x: number, y: number): void;
|
|
44
|
+
scrollBy(opts?: ScrollToOptions): void;
|
|
45
|
+
scrollBy(x: number, y: number): void;
|
|
46
|
+
}
|
|
47
|
+
export class EvoScrollContainerElement extends HTMLElement implements IEvoScrollContainerElement {
|
|
29
48
|
static get htmlTagName() {
|
|
30
49
|
return 'evo-scroll-container';
|
|
31
50
|
}
|
|
32
51
|
|
|
33
52
|
#content!: HTMLElement;
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
53
|
+
#trackHorz: HTMLElement | null = null;
|
|
54
|
+
#thumbHorz: HTMLElement | null = null;
|
|
55
|
+
#trackVert: HTMLElement | null = null;
|
|
56
|
+
#thumbVert: HTMLElement | null = null;
|
|
57
|
+
#isDraggingVert: boolean = false;
|
|
37
58
|
#startY: number = 0;
|
|
38
59
|
#startScrollTop: number = 0;
|
|
39
|
-
|
|
60
|
+
#isDraggingHorz: boolean = false;
|
|
61
|
+
#startX: number = 0;
|
|
62
|
+
#startScrollLeft: number = 0;
|
|
63
|
+
#scrolling: Scrolling = 'vertical';
|
|
64
|
+
|
|
40
65
|
#scrollbarSettings: ScrollbarSettings = {};
|
|
41
|
-
#
|
|
42
|
-
#
|
|
66
|
+
#mouseupHandlerVert: any = undefined;
|
|
67
|
+
#mousemoveHandlerVert: any = undefined;
|
|
68
|
+
#mouseupHandlerHorz: any = undefined;
|
|
69
|
+
#mousemoveHandlerHorz: any = undefined;
|
|
43
70
|
#boundResizeHandler: () => void;
|
|
44
71
|
|
|
45
72
|
constructor() {
|
|
@@ -49,24 +76,36 @@ export class EvoScrollContainerElement extends HTMLElement {
|
|
|
49
76
|
|
|
50
77
|
connectedCallback() {
|
|
51
78
|
this.#content = this.querySelector('.evo-scroll-content') as HTMLElement;
|
|
52
|
-
this.#
|
|
53
|
-
this.#
|
|
54
|
-
this.#
|
|
79
|
+
this.#trackHorz = this.querySelector<HTMLElement>('.evo-scroll-track-horz');
|
|
80
|
+
this.#thumbHorz = this.querySelector<HTMLElement>('.evo-scroll-track-horz .evo-scroll-thumb');
|
|
81
|
+
this.#trackVert = this.querySelector<HTMLElement>('.evo-scroll-track-vert');
|
|
82
|
+
this.#thumbVert = this.querySelector<HTMLElement>('.evo-scroll-track-vert .evo-scroll-thumb');
|
|
83
|
+
this.#isDraggingVert = false;
|
|
55
84
|
this.#startY = 0;
|
|
56
85
|
this.#startScrollTop = 0;
|
|
57
86
|
|
|
58
|
-
this.#
|
|
87
|
+
this.#thumbVert?.addEventListener('mousedown', this.#thumbMouseDownVert.bind(this));
|
|
88
|
+
this.#thumbHorz?.addEventListener('mousedown', this.#thumbMouseDownHorz.bind(this));
|
|
59
89
|
this.#content.addEventListener('scroll', this.#scrollContent.bind(this), { passive: true });
|
|
90
|
+
this.#scrolling = (this.dataset.scrolling as Scrolling) ?? 'vertical';
|
|
60
91
|
|
|
61
92
|
intersectionObserver.observe(this);
|
|
62
93
|
mutationObserver.observe(this, { attributes: true, childList: true, subtree: true });
|
|
63
94
|
|
|
64
95
|
window.addEventListener('resize', this.#boundResizeHandler, { passive: true });
|
|
96
|
+
if (this.#scrolling === 'horizontal') {
|
|
97
|
+
this.addEventListener('wheel', this.#wheelHorz, { passive: true });
|
|
98
|
+
}
|
|
65
99
|
}
|
|
66
100
|
|
|
67
101
|
disconnectedCallback() {
|
|
68
102
|
intersectionObserver.unobserve(this);
|
|
69
|
-
window.removeEventListener('resize', this.#boundResizeHandler);
|
|
103
|
+
window.removeEventListener('resize', this.#boundResizeHandler);
|
|
104
|
+
this.removeEventListener('wheel', this.#wheelHorz);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get content() {
|
|
108
|
+
return this.#content;
|
|
70
109
|
}
|
|
71
110
|
|
|
72
111
|
scroll(opts?: ScrollToOptions): void;
|
|
@@ -132,79 +171,138 @@ export class EvoScrollContainerElement extends HTMLElement {
|
|
|
132
171
|
}
|
|
133
172
|
|
|
134
173
|
#updateThumbSize() {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
174
|
+
if (this.#thumbVert && this.#trackVert) {
|
|
175
|
+
const scrollHeight = this.#content.scrollHeight - getPaddingY(this.#content);
|
|
176
|
+
const containerHeight = this.clientHeight - getPaddingY(this);
|
|
177
|
+
const trackHeight = this.#trackVert.clientHeight;
|
|
178
|
+
|
|
179
|
+
const visibleRatioVert = containerHeight / scrollHeight;
|
|
180
|
+
const thumbHeight = visibleRatioVert * trackHeight;
|
|
181
|
+
if (this.#scrollbarSettings.thumbHeight != undefined) {
|
|
182
|
+
this.#thumbVert.style.height = `${Math.max(0, Math.min(this.#scrollbarSettings.thumbHeight, trackHeight))}px`;
|
|
183
|
+
} else {
|
|
184
|
+
this.#thumbVert.style.height = `${Math.min(thumbHeight > 20 ? thumbHeight : 20, trackHeight)}px`;
|
|
185
|
+
}
|
|
186
|
+
if (this.#scrollbarSettings.trackVisible !== undefined) {
|
|
187
|
+
this.#trackVert.style.display = this.#scrollbarSettings.trackVisible === true ? 'block' : 'none';
|
|
188
|
+
} else {
|
|
189
|
+
this.#trackVert.style.display = visibleRatioVert < 1 ? 'block' : 'none';
|
|
190
|
+
}
|
|
150
191
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
192
|
+
|
|
193
|
+
if (this.#thumbHorz && this.#trackHorz) {
|
|
194
|
+
const scrollWidth = this.#content.scrollWidth - getPaddingX(this.#content);
|
|
195
|
+
const containerWidth = this.clientWidth - getPaddingX(this);
|
|
196
|
+
const trackWidth = this.#trackHorz.clientWidth;
|
|
197
|
+
|
|
198
|
+
const visibleRatioHorz = containerWidth / scrollWidth;
|
|
199
|
+
const thumbWidth = visibleRatioHorz * trackWidth;
|
|
200
|
+
this.#thumbHorz.style.width = `${Math.min(thumbWidth > 20 ? thumbWidth : 20, trackWidth)}px`;
|
|
201
|
+
if (this.#scrollbarSettings.trackVisible !== undefined) {
|
|
202
|
+
this.#trackHorz.style.display = this.#scrollbarSettings.trackVisible === true ? 'block' : 'none';
|
|
203
|
+
} else {
|
|
204
|
+
this.#trackHorz.style.display = visibleRatioHorz < 1 ? 'block' : 'none';
|
|
205
|
+
}
|
|
155
206
|
}
|
|
156
|
-
|
|
157
207
|
}
|
|
158
208
|
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
this.#
|
|
162
|
-
|
|
163
|
-
document.addEventListener('
|
|
164
|
-
document.addEventListener('
|
|
165
|
-
this.#
|
|
209
|
+
#thumbMouseDownVert(e: MouseEvent) {
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
this.#mouseupHandlerVert = this.#mouseDetachVert.bind(this);
|
|
212
|
+
this.#mousemoveHandlerVert = this.#thumbMouseMoveVert.bind(this);
|
|
213
|
+
document.addEventListener('mouseup', this.#mouseupHandlerVert, { passive: true });
|
|
214
|
+
document.addEventListener('dragend', this.#mouseupHandlerVert, { passive: true });
|
|
215
|
+
document.addEventListener('mousemove', this.#mousemoveHandlerVert, { passive: true });
|
|
216
|
+
this.#isDraggingVert = true;
|
|
166
217
|
this.#startY = e.clientY;
|
|
167
218
|
this.#startScrollTop = this.#content.scrollTop;
|
|
168
|
-
this.#
|
|
219
|
+
this.#thumbVert!.style.cursor = 'grabbing';
|
|
169
220
|
}
|
|
170
221
|
|
|
171
|
-
#
|
|
172
|
-
if (this.#
|
|
222
|
+
#thumbMouseMoveVert(e: MouseEvent) {
|
|
223
|
+
if (this.#isDraggingVert) {
|
|
173
224
|
const deltaY = e.clientY - this.#startY;
|
|
174
|
-
const thumbTrackHeight = this.clientHeight - this.#
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const scrollRatio =
|
|
181
|
-
(this.#content.scrollHeight - this.clientHeight) / thumbTrackHeight;
|
|
182
|
-
|
|
225
|
+
const thumbTrackHeight = this.clientHeight - this.#thumbVert!.clientHeight;
|
|
226
|
+
if (thumbTrackHeight <= 0) return;
|
|
227
|
+
const scrollRatio = (this.#content.scrollHeight - this.clientHeight) / thumbTrackHeight;
|
|
183
228
|
this.#content.scrollTop = this.#startScrollTop + deltaY * scrollRatio;
|
|
184
229
|
} else {
|
|
185
|
-
this.#
|
|
230
|
+
this.#mouseDetachVert();
|
|
186
231
|
}
|
|
187
232
|
}
|
|
188
233
|
|
|
189
|
-
#
|
|
190
|
-
this.#
|
|
191
|
-
this.#
|
|
192
|
-
document.removeEventListener('mouseup', this.#
|
|
193
|
-
document.removeEventListener('dragend', this.#
|
|
194
|
-
document.removeEventListener('mousemove', this.#
|
|
234
|
+
#mouseDetachVert() {
|
|
235
|
+
this.#isDraggingVert = false;
|
|
236
|
+
this.#thumbVert!.style.cursor = 'grab';
|
|
237
|
+
document.removeEventListener('mouseup', this.#mouseupHandlerVert);
|
|
238
|
+
document.removeEventListener('dragend', this.#mouseupHandlerVert);
|
|
239
|
+
document.removeEventListener('mousemove', this.#mousemoveHandlerVert);
|
|
195
240
|
}
|
|
196
241
|
|
|
197
|
-
#
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
242
|
+
#thumbMouseDownHorz(e: MouseEvent) {
|
|
243
|
+
e.preventDefault();
|
|
244
|
+
this.#mouseupHandlerHorz = this.#mouseDetachHorz.bind(this);
|
|
245
|
+
this.#mousemoveHandlerHorz = this.#thumbMouseMoveHorz.bind(this);
|
|
246
|
+
document.addEventListener('mouseup', this.#mouseupHandlerHorz, { passive: true });
|
|
247
|
+
document.addEventListener('dragend', this.#mouseupHandlerHorz, { passive: true });
|
|
248
|
+
document.addEventListener('mousemove', this.#mousemoveHandlerHorz, { passive: true });
|
|
249
|
+
this.#isDraggingHorz = true;
|
|
250
|
+
this.#startX = e.clientX;
|
|
251
|
+
this.#startScrollLeft = this.#content.scrollLeft;
|
|
252
|
+
this.#thumbHorz!.style.cursor = 'grabbing';
|
|
253
|
+
}
|
|
201
254
|
|
|
202
|
-
|
|
203
|
-
|
|
255
|
+
#thumbMouseMoveHorz(e: MouseEvent) {
|
|
256
|
+
if (this.#isDraggingHorz) {
|
|
257
|
+
const deltaX = e.clientX - this.#startX;
|
|
258
|
+
const thumbTrackWidth = this.clientWidth - this.#thumbHorz!.clientWidth;
|
|
259
|
+
if (thumbTrackWidth <= 0) return;
|
|
260
|
+
const scrollRatio = (this.#content.scrollWidth - this.clientWidth) / thumbTrackWidth;
|
|
261
|
+
this.#content.scrollLeft = this.#startScrollLeft + deltaX * scrollRatio;
|
|
204
262
|
} else {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
263
|
+
this.#mouseDetachHorz();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
#mouseDetachHorz() {
|
|
268
|
+
this.#isDraggingHorz = false;
|
|
269
|
+
this.#thumbHorz!.style.cursor = 'grab';
|
|
270
|
+
document.removeEventListener('mouseup', this.#mouseupHandlerHorz);
|
|
271
|
+
document.removeEventListener('dragend', this.#mouseupHandlerHorz);
|
|
272
|
+
document.removeEventListener('mousemove', this.#mousemoveHandlerHorz);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#wheelHorz(e: WheelEvent) {
|
|
276
|
+
this.scrollLeft += e.deltaY;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
#scrollContent() {
|
|
280
|
+
if (this.#thumbVert && this.#trackVert) {
|
|
281
|
+
const scrollHeight = this.#content.scrollHeight - getPaddingY(this.#content);
|
|
282
|
+
const containerHeight = this.clientHeight - getPaddingY(this);
|
|
283
|
+
const scrollableHeight = scrollHeight - containerHeight;
|
|
284
|
+
if (scrollableHeight <= 0) {
|
|
285
|
+
this.#thumbVert.style.top = '0px';
|
|
286
|
+
} else {
|
|
287
|
+
const scrollRatio = this.#content.scrollTop / scrollableHeight;
|
|
288
|
+
const maxTop = this.#trackVert.clientHeight - this.#thumbVert.clientHeight;
|
|
289
|
+
const top = Math.max(0, Math.min(scrollRatio * maxTop, maxTop));
|
|
290
|
+
this.#thumbVert.style.top = `${top}px`;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (this.#thumbHorz && this.#trackHorz) {
|
|
295
|
+
const scrollWidth = this.#content.scrollWidth - getPaddingX(this.#content);
|
|
296
|
+
const containerWidth = this.clientWidth - getPaddingX(this);
|
|
297
|
+
const scrollableWidth = scrollWidth - containerWidth;
|
|
298
|
+
if (scrollableWidth <= 0) {
|
|
299
|
+
this.#thumbHorz.style.left = '0px';
|
|
300
|
+
} else {
|
|
301
|
+
const scrollRatio = this.#content.scrollLeft / scrollableWidth;
|
|
302
|
+
const maxLeft = this.#trackHorz.clientWidth - this.#thumbHorz.clientWidth;
|
|
303
|
+
const left = Math.max(0, Math.min(scrollRatio * maxLeft, maxLeft));
|
|
304
|
+
this.#thumbHorz.style.left = `${left}px`;
|
|
305
|
+
}
|
|
208
306
|
}
|
|
209
307
|
}
|
|
210
308
|
}
|
|
@@ -270,3 +368,8 @@ function getPaddingY(content: HTMLElement): number {
|
|
|
270
368
|
const style = getComputedStyle(content);
|
|
271
369
|
return parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
272
370
|
}
|
|
371
|
+
|
|
372
|
+
function getPaddingX(content: HTMLElement): number {
|
|
373
|
+
const style = getComputedStyle(content);
|
|
374
|
+
return parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
375
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as FlipCard } from './FlipCard/FlipCard.astro';
|
|
2
|
+
export { default as RightISI } from './ISI/Right/RightISI.astro';
|
|
2
3
|
export { default as Modal } from './Modal/Modal.astro';
|
|
3
4
|
export { default as ModalOverlay } from './Modal/ModalOverlay.astro';
|
|
4
5
|
export { default as ModalTrigger } from './Modal/ModalTrigger.astro';
|
package/src/lib/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as FlipCard from '../components/FlipCard/FlipCard';
|
|
2
|
+
export * as ISI from '../components/ISI/index';
|
|
3
|
+
export * as gestures from './gestures';
|
|
2
4
|
export * as Modal from '../components/Modal/Modal';
|
|
3
5
|
export * as PdfViewer from '../components/PdfViewer/PdfViewer';
|
|
4
6
|
export * as ScrollContainer from '../components/ScrollContainer/ScrollContainer';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--evo-isi-width: 25vw;
|
|
3
|
-
--evo-isi-width-expanded: 100vw;
|
|
4
|
-
--evo-isi-height: 100vh;
|
|
5
|
-
--evo-isi-header-height: 0px;
|
|
6
|
-
--evo-isi-footer-height: 0px;
|
|
7
|
-
}
|
|
8
|
-
.evo-isi {
|
|
9
|
-
position: fixed;
|
|
10
|
-
right: 0;
|
|
11
|
-
top: 0;
|
|
12
|
-
display: block;
|
|
13
|
-
width: var(--evo-isi-width);
|
|
14
|
-
height: var(--evo-isi-height);
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
z-index: 99;
|
|
17
|
-
background-color: #ffffff;
|
|
18
|
-
|
|
19
|
-
transform-origin: right top;
|
|
20
|
-
transition-property: width;
|
|
21
|
-
transition-duration: 500ms;
|
|
22
|
-
transition-timing-function: ease-in-out;
|
|
23
|
-
|
|
24
|
-
.evo-isi-wrapper {
|
|
25
|
-
.evo-isi-text {
|
|
26
|
-
.evo-scroll-container {
|
|
27
|
-
/* height: calc(var(--evo-isi-height) - var(--evo-isi-header-height) - var(--evo-isi-footer-height)) */
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as ScrollContainer from '../ScrollContainer/ScrollContainer';
|
|
2
|
-
|
|
3
|
-
const isi = document.querySelector('.evo-isi') as HTMLElement;
|
|
4
|
-
const isiHeader = isi.querySelector<HTMLElement>('.evo-isi-header');
|
|
5
|
-
const isiFooter = isi.querySelector<HTMLElement>('.evo-isi-footer');
|
|
6
|
-
const isiText = isi.querySelector('.evo-isi-text') as HTMLElement;
|
|
7
|
-
|
|
8
|
-
export function resize() {
|
|
9
|
-
if (isi) {
|
|
10
|
-
const isiStyle = getComputedStyle(isi);
|
|
11
|
-
const isiHeight = parseInt(isiStyle.height);
|
|
12
|
-
const headerHeight = isiHeader ? parseInt(getComputedStyle(isiHeader).height) : 0;
|
|
13
|
-
const footerHeight = isiFooter ? parseInt(getComputedStyle(isiFooter).height) : 0;
|
|
14
|
-
|
|
15
|
-
const isiTextStyle = getComputedStyle(isiText);
|
|
16
|
-
const textPadTop = parseInt(isiTextStyle.paddingTop);
|
|
17
|
-
const textPadBot = parseInt(isiTextStyle.paddingBottom);
|
|
18
|
-
|
|
19
|
-
const scrollContainer = ScrollContainer.getScrollContainer(isi.querySelector('.evo-isi-text .evo-scroll-container') as HTMLElement);
|
|
20
|
-
if (scrollContainer) {
|
|
21
|
-
const height = isiHeight - headerHeight - footerHeight - textPadTop - textPadBot;
|
|
22
|
-
ScrollContainer.resize(scrollContainer, { height });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
addEventListener('load', resize, { passive: true });
|
|
27
|
-
window.addEventListener('resize', resize, { passive: true });
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
import './Modal.css';
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<'div'> {
|
|
6
|
-
id: string;
|
|
7
|
-
closeButton?: 'default' | 'minimal' | 'none' | 'false' | false;
|
|
8
|
-
closeButtonAtts?: Record<string, string>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
id,
|
|
13
|
-
closeButton = 'default',
|
|
14
|
-
closeButtonAtts,
|
|
15
|
-
...rest
|
|
16
|
-
} = Astro.props;
|
|
17
|
-
|
|
18
|
-
const attrs = {...rest};
|
|
19
|
-
const cssClass = attrs['class'] ?? '';
|
|
20
|
-
|
|
21
|
-
['class'].forEach((a) => {
|
|
22
|
-
delete attrs[a as keyof typeof attrs];
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const showCloseButton = closeButton !== false && closeButton !== 'false' && closeButton !== 'none';
|
|
26
|
-
const closeButtonCssClassList = ['evo-modal-close', 'evo-modal-action-hide'];
|
|
27
|
-
if (showCloseButton) {
|
|
28
|
-
closeButtonCssClassList.push(`evo-modal-theme-${closeButton}`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
<evo-modal id={id} class:list={['evo-modal', cssClass]} {...attrs}>
|
|
33
|
-
{showCloseButton && <button class:list={closeButtonCssClassList} {...closeButtonAtts}><span class="evo-modal-x"><slot name="close">X</slot></span></button>}
|
|
34
|
-
<slot name="outer" />
|
|
35
|
-
<div class="evo-modal-wrapper">
|
|
36
|
-
<slot />
|
|
37
|
-
</div>
|
|
38
|
-
</evo-modal>
|
|
39
|
-
|
|
40
|
-
<script>
|
|
41
|
-
import './Modal';
|
|
42
|
-
</script>
|