vanilla-drawers 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +91 -3
- package/dist/style.css +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
@@ -1,18 +1,106 @@
|
|
1
1
|
# drawers
|
2
2
|
|
3
|
+
Система работает поверх уже подготовленной разметки, не модифицирует структуру DOM.
|
4
|
+
|
3
5
|
# ready
|
4
6
|
* Окно открытое позже имеет больший zIndex чем окно открытое ранее
|
5
|
-
* Возможность задать фиксированный zIndex
|
7
|
+
* Возможность задать фиксированный zIndex (на самом деле, zIndex не устанавливается в inline стили, в прописывается в css переменную --z-index, что дает возможность задать произвольный zIndex)
|
6
8
|
* Возможность закрытия по нажатию Esc
|
7
9
|
* Возможность закрытия по нажатию вне тела окна, с опцией проверки объекта, на котором произошло нажатие, например,если в теле модалки было открыто стороннее диалоговое окно, то по нажатие внутри этого диалогового окна не закрывалось текущее.
|
8
10
|
* Возможность подтверждения закрытия.
|
9
|
-
* Поддержка создания группы
|
11
|
+
* Поддержка создания группы окон, окна считают свой zIndex относительно других окон в группе, но не всех существующих.
|
10
12
|
* Каждая отедельная группа может установить блокировку скролла ближайшего к ней контейнера `[data-scrollable], html`
|
13
|
+
(добавляет class scroll-lock-by-drawer)
|
14
|
+
* Служебный класс drawer-trigger_active добавляется ко всем связанным тригерам (кнопкам открытия/закрытия), пока окно открыто
|
11
15
|
|
12
16
|
# to do
|
13
17
|
* Набор встроенных диалоговых окон alert, confirm, prompt etc
|
18
|
+
* Опционально фокус на первом поле вводе по открытию
|
14
19
|
* Назначение окну индекса внутри группы [data-drawer-id]
|
15
20
|
* Возможность переключаться между немодальными окнами в группе (изменение zIndex)
|
16
21
|
* Возможность вкладывать группу в группу
|
17
22
|
* Если клик произошел внутри модального окна, то событие этого клика не должно закрывать другие окна
|
18
|
-
(На данный момент
|
23
|
+
(На данный момент события клика внутри других окон игнорируются безусловно)
|
24
|
+
|
25
|
+
# get started
|
26
|
+
Подключаем через cdn, например так:
|
27
|
+
```
|
28
|
+
<script defer src="https://cdn.jsdelivr.net/npm/vanilla-drawers@1.0.11/dist/drawers.umd.js"></script>
|
29
|
+
```
|
30
|
+
|
31
|
+
# Пример разметки (в исходниках есть demo):
|
32
|
+
```
|
33
|
+
<body>
|
34
|
+
<div class="triggers">
|
35
|
+
<button type="button" data-drawer-open="example-1">Open example-1</button>
|
36
|
+
</div>
|
37
|
+
<!-- Будет помещен в группу "default" -->
|
38
|
+
<div class="drawer" data-drawer="example-1">
|
39
|
+
<div class="drawer__panel" data-elem="drawer.panel">
|
40
|
+
<div class="drawer__body">
|
41
|
+
<div class="drawer__inner">
|
42
|
+
<button type="button" data-drawer-close="example-1">Close example-1</button>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<!-- Создание группы окон "system", обязателен только атрибут data-drawers-group -->
|
48
|
+
<div class="drawers-group" data-drawers-group="system">
|
49
|
+
<!-- data-drawer="example-2" Обязательный атрибут, позволяющий скрипту найти окно и назначить alias -->
|
50
|
+
<div class="drawer" data-drawer="example-2">
|
51
|
+
<!-- data-elem="drawer.panel" Обязательный атрибут, позволяющий скрипту найти панель окна (могут быть какие угодна прослойки выше, оборачивающие панель) -->
|
52
|
+
<div class="drawer__panel" data-elem="drawer.panel">
|
53
|
+
<div class="drawer__body">
|
54
|
+
<div class="drawer__inner">
|
55
|
+
<button type="button" data-drawer-close="example-2">Close example-2</button>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
</body>
|
62
|
+
```
|
63
|
+
# Пример стилей (в исходниках есть demo):
|
64
|
+
```
|
65
|
+
.drawers-group {
|
66
|
+
position: fixed;
|
67
|
+
left: 0;
|
68
|
+
top: 0;
|
69
|
+
width: 100%;
|
70
|
+
height: 100%;
|
71
|
+
pointer-events: none;
|
72
|
+
}
|
73
|
+
.drawers-group > * {
|
74
|
+
pointer-events: all;
|
75
|
+
}
|
76
|
+
.drawer {
|
77
|
+
display: flex;
|
78
|
+
justify-content: center;
|
79
|
+
position: fixed;
|
80
|
+
z-index: var(--z-index);
|
81
|
+
left: 0;
|
82
|
+
top: 0;
|
83
|
+
width: 100%;
|
84
|
+
height: 100%;
|
85
|
+
overflow: hidden;
|
86
|
+
background-color: rgba(78, 78, 78, 0.342);
|
87
|
+
}
|
88
|
+
.drawer__panel {
|
89
|
+
display: flex;
|
90
|
+
height: 100%;
|
91
|
+
width: 100%;
|
92
|
+
max-width: 600px;
|
93
|
+
max-height: 400px;
|
94
|
+
margin: auto;
|
95
|
+
overflow-x: hidden;
|
96
|
+
transition: visibility 0.4s, opacity 0.4s, transform 0.4s;
|
97
|
+
}
|
98
|
+
.drawer__body {
|
99
|
+
width: 100%;
|
100
|
+
}
|
101
|
+
.drawer:not(.drawer_open), .drawer:not(.drawer_open) .drawer__panel {
|
102
|
+
visibility: hidden;
|
103
|
+
opacity: 0;
|
104
|
+
transform: none;
|
105
|
+
}
|
106
|
+
```
|
package/dist/style.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
html{overflow-x:hidden;scroll-behavior:auto}body{position:fixed;left:0;top:0;width:100%;background-color:#fff;height:100vh;overflow:hidden;margin:0;scroll-behavior:auto}.drawers-group{position:fixed;left:0;top:0;width:100%;height:100%;pointer-events:none}.drawers
|
1
|
+
html{overflow-x:hidden;scroll-behavior:auto}body{position:fixed;left:0;top:0;width:100%;background-color:#fff;height:100vh;overflow:hidden;margin:0;scroll-behavior:auto}.drawers-group{position:fixed;left:0;top:0;width:100%;height:100%;pointer-events:none}.drawers-group>*{pointer-events:all}.drawer{display:flex;justify-content:center;position:fixed;z-index:var(--z-index);left:0;top:0;width:100%;height:100%;overflow:hidden;background-color:#4e4e4e57}.drawer__panel{display:flex;height:100%;width:100%;max-width:600px;max-height:400px;margin:auto;overflow-x:hidden}.drawer__panel{transition:visibility .4s,opacity .4s,transform .4s}.drawer:not(.drawer_open),.drawer:not(.drawer_open) .drawer__panel{visibility:hidden;opacity:0;transform:none}.drawer__body{width:100%}.drawer:nth-child(1) .drawer__body{background-color:#0ff}.drawer:nth-child(2) .drawer__body{background-color:#8a2be2}.drawer:nth-child(3) .drawer__body{background-color:brown}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vanilla-drawers",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.13",
|
4
4
|
"description": "Drawers controller.",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -19,7 +19,7 @@
|
|
19
19
|
},
|
20
20
|
"repository": {
|
21
21
|
"type": "git",
|
22
|
-
"url": "git+https://github.com/techno-trump/drawers.git"
|
22
|
+
"url": "git+https://github.com/techno-trump/vanilla-drawers.git"
|
23
23
|
},
|
24
24
|
"keywords": [
|
25
25
|
"drawer",
|
@@ -30,9 +30,9 @@
|
|
30
30
|
"author": "Anton Kalinichenko",
|
31
31
|
"license": "GPL-3.0",
|
32
32
|
"bugs": {
|
33
|
-
"url": "https://github.com/techno-trump/drawers/issues"
|
33
|
+
"url": "https://github.com/techno-trump/vanilla-drawers/issues"
|
34
34
|
},
|
35
|
-
"homepage": "https://github.com/techno-trump/drawers#readme",
|
35
|
+
"homepage": "https://github.com/techno-trump/vanilla-drawers#readme",
|
36
36
|
"devDependencies": {
|
37
37
|
"@babel/core": "^7.23.6",
|
38
38
|
"@babel/plugin-transform-class-properties": "^7.23.3",
|