turbo_modal 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/javascript/turbo_modal/scrim_controller.js +24 -15
- data/lib/turbo_modal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109ad54770b4ca4dbf21878bc8c71b8cf26ab1419b94428c9b5e2f6f3039d6f6
|
4
|
+
data.tar.gz: 53074315c672b7872ddf00f7eb450ea1f211258ec846afd885e43867e80cd6fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b80f44d4a426e6b22e781c3b602c8a93b4e713e83ad5d19f2811fbdda5fb51534cc7e01a8fb708dece3dc8e1884f3c79b6bd56528f46a86875c48ef5bdd28b
|
7
|
+
data.tar.gz: b70024cf95327a99d3efe987c1f446031fb2b35e233f993a5cb7e8c35be851b7607fd47c9e2633d01d0f85f27bbde6dae6456ff7bf427f61368fefb53f57b9d9
|
@@ -14,37 +14,36 @@ class ScrimController extends Controller {
|
|
14
14
|
static targets = ["scrim"];
|
15
15
|
|
16
16
|
show(event) {
|
17
|
+
clipScreen(this);
|
17
18
|
delete this.scrimTarget.dataset.hidden;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if (!event.detail.dismiss) {
|
22
|
-
this.scrimTarget.style.pointerEvents = "none";
|
19
|
+
if (event.detail.dismissable) {
|
20
|
+
this.scrimTarget.dataset.dismissable = "";
|
23
21
|
}
|
24
22
|
}
|
25
23
|
|
26
|
-
hide(event) {
|
24
|
+
hide(event = null) {
|
25
|
+
delete this.scrimTarget.dataset.dismissable;
|
27
26
|
this.scrimTarget.dataset.hidden = "";
|
28
|
-
unclipScreen();
|
27
|
+
unclipScreen(this);
|
29
28
|
}
|
30
29
|
|
31
30
|
onClick(event) {
|
32
|
-
|
31
|
+
if (this.scrimTarget.dataset.dismissable) {
|
32
|
+
window.dispatchEvent(new Event("scrim:hide"));
|
33
|
+
}
|
33
34
|
}
|
34
35
|
|
35
36
|
disconnect() {
|
36
|
-
this.
|
37
|
-
unclipScreen();
|
37
|
+
this.hide();
|
38
38
|
super.disconnect();
|
39
39
|
}
|
40
|
-
|
41
40
|
}
|
42
41
|
|
43
42
|
/**
|
44
43
|
* Show the scrim element
|
45
44
|
*/
|
46
45
|
function showScrim(dismiss = true) {
|
47
|
-
window.dispatchEvent(new CustomEvent("scrim:show", { detail: {
|
46
|
+
window.dispatchEvent(new CustomEvent("scrim:show", { detail: { dismissable: dismiss } }));
|
48
47
|
}
|
49
48
|
|
50
49
|
/**
|
@@ -54,12 +53,22 @@ function hideScrim() {
|
|
54
53
|
window.dispatchEvent(new Event("scrim:hide"));
|
55
54
|
}
|
56
55
|
|
56
|
+
/**
|
57
|
+
* Clips body to viewport size
|
58
|
+
*/
|
59
|
+
function clipScreen(controller) {
|
60
|
+
controller.previousHeight = document.body.style.height || "unset";
|
61
|
+
controller.previousOverflow = document.body.style.overflow || "unset";
|
62
|
+
document.body.style.height = "100vh";
|
63
|
+
document.body.style.overflow = "hidden";
|
64
|
+
}
|
65
|
+
|
57
66
|
/**
|
58
67
|
* Unclips body to viewport size
|
59
68
|
*/
|
60
|
-
function unclipScreen() {
|
61
|
-
document.body.style.height =
|
62
|
-
document.body.style.overflow =
|
69
|
+
function unclipScreen(controller) {
|
70
|
+
document.body.style.height = controller.previousHeight;
|
71
|
+
document.body.style.overflow = controller.previousOverflow;
|
63
72
|
}
|
64
73
|
|
65
74
|
export { ScrimController as default, showScrim, hideScrim }
|
data/lib/turbo_modal/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_modal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Cornthwaite
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-05-
|
12
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|