bootstrap-rn 0.3.2 → 0.3.3
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.
|
@@ -73,7 +73,7 @@ const styles = _StyleSheet.default.create({
|
|
|
73
73
|
width: auto;
|
|
74
74
|
margin: $modal-dialog-margin;
|
|
75
75
|
// allow clicks to pass through for custom click handling to close modal
|
|
76
|
-
pointer-events: none;
|
|
76
|
+
pointer-events: auto; // pointer-events: none;
|
|
77
77
|
|
|
78
78
|
@include media-breakpoint-up(sm) {
|
|
79
79
|
width: 100%; // added for bootstrap-rn
|
|
@@ -64,7 +64,7 @@ const styles = StyleSheet.create({
|
|
|
64
64
|
width: auto;
|
|
65
65
|
margin: $modal-dialog-margin;
|
|
66
66
|
// allow clicks to pass through for custom click handling to close modal
|
|
67
|
-
pointer-events: none;
|
|
67
|
+
pointer-events: auto; // pointer-events: none;
|
|
68
68
|
|
|
69
69
|
@include media-breakpoint-up(sm) {
|
|
70
70
|
width: 100%; // added for bootstrap-rn
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bootstrap-rn",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Bootstrap RN is a design framework for React Native. The library is inspired by Bootstrap and tries to bring best practices from the Sass/Css world to JavaScript.",
|
|
5
5
|
"author": "Markus Wetzel <markuswetzel@gmx.net>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,7 +66,7 @@ const styles = StyleSheet.create({
|
|
|
66
66
|
width: auto;
|
|
67
67
|
margin: $modal-dialog-margin;
|
|
68
68
|
// allow clicks to pass through for custom click handling to close modal
|
|
69
|
-
pointer-events: none;
|
|
69
|
+
pointer-events: auto; // pointer-events: none;
|
|
70
70
|
|
|
71
71
|
@include media-breakpoint-up(sm) {
|
|
72
72
|
width: 100%; // added for bootstrap-rn
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { useRef, useMemo } from 'react';
|
|
2
|
-
import { Platform, findNodeHandle } from 'react-native';
|
|
3
|
-
|
|
4
|
-
const computeScrollbarWidth = () => {
|
|
5
|
-
const documentWidth = document.documentElement.clientWidth;
|
|
6
|
-
return Math.abs(window.innerWidth - documentWidth);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default function useScrollbarEffects(elements) {
|
|
10
|
-
if (Platform.OS !== 'web') {
|
|
11
|
-
return useMemo(
|
|
12
|
-
() => ({
|
|
13
|
-
hide() {},
|
|
14
|
-
show() {},
|
|
15
|
-
}),
|
|
16
|
-
[],
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const state = useRef({
|
|
21
|
-
counter: 0,
|
|
22
|
-
elements: [],
|
|
23
|
-
originalWidths: [],
|
|
24
|
-
originalBodyOverflow: '',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return useMemo(
|
|
28
|
-
() => ({
|
|
29
|
-
hide() {
|
|
30
|
-
state.current.counter += 1;
|
|
31
|
-
|
|
32
|
-
if (state.current.counter !== 1) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const rect = document.body.getBoundingClientRect();
|
|
37
|
-
const isBodyOverflowing = rect.left + rect.right < window.innerWidth;
|
|
38
|
-
|
|
39
|
-
// Set body and fixed elements padding adjustments.
|
|
40
|
-
const fixedElements = elements
|
|
41
|
-
.filter((ref) => ref.current)
|
|
42
|
-
.map((ref) => findNodeHandle(ref.current));
|
|
43
|
-
state.current.elements = [document.body, ...fixedElements];
|
|
44
|
-
|
|
45
|
-
state.current.originalWidths = state.current.elements.map(
|
|
46
|
-
(el) => el.style.width || '',
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
state.current.originalBodyOverflow = document.body.style.overflow || '';
|
|
50
|
-
|
|
51
|
-
if (isBodyOverflowing) {
|
|
52
|
-
const scrollbarWidth = computeScrollbarWidth();
|
|
53
|
-
|
|
54
|
-
state.current.elements.forEach((el) => {
|
|
55
|
-
// eslint-disable-next-line no-param-reassign
|
|
56
|
-
el.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Add "overflow: hidden" to body element.
|
|
61
|
-
document.body.style.overflow = 'hidden';
|
|
62
|
-
},
|
|
63
|
-
show() {
|
|
64
|
-
state.current.counter -= 1;
|
|
65
|
-
|
|
66
|
-
if (state.current.counter !== 0) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Remove "overflow: hidden" from body element.
|
|
71
|
-
document.body.style.overflow = state.current.originalBodyOverflow;
|
|
72
|
-
|
|
73
|
-
// Reset body padding adjustments.
|
|
74
|
-
state.current.elements.forEach((el, key) => {
|
|
75
|
-
// eslint-disable-next-line no-param-reassign
|
|
76
|
-
el.style.width = state.current.originalWidths[key] || '';
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
[],
|
|
81
|
-
);
|
|
82
|
-
}
|
|
1
|
+
import { useRef, useMemo } from 'react';
|
|
2
|
+
import { Platform, findNodeHandle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const computeScrollbarWidth = () => {
|
|
5
|
+
const documentWidth = document.documentElement.clientWidth;
|
|
6
|
+
return Math.abs(window.innerWidth - documentWidth);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function useScrollbarEffects(elements) {
|
|
10
|
+
if (Platform.OS !== 'web') {
|
|
11
|
+
return useMemo(
|
|
12
|
+
() => ({
|
|
13
|
+
hide() {},
|
|
14
|
+
show() {},
|
|
15
|
+
}),
|
|
16
|
+
[],
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const state = useRef({
|
|
21
|
+
counter: 0,
|
|
22
|
+
elements: [],
|
|
23
|
+
originalWidths: [],
|
|
24
|
+
originalBodyOverflow: '',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
hide() {
|
|
30
|
+
state.current.counter += 1;
|
|
31
|
+
|
|
32
|
+
if (state.current.counter !== 1) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const rect = document.body.getBoundingClientRect();
|
|
37
|
+
const isBodyOverflowing = rect.left + rect.right < window.innerWidth;
|
|
38
|
+
|
|
39
|
+
// Set body and fixed elements padding adjustments.
|
|
40
|
+
const fixedElements = elements
|
|
41
|
+
.filter((ref) => ref.current)
|
|
42
|
+
.map((ref) => findNodeHandle(ref.current));
|
|
43
|
+
state.current.elements = [document.body, ...fixedElements];
|
|
44
|
+
|
|
45
|
+
state.current.originalWidths = state.current.elements.map(
|
|
46
|
+
(el) => el.style.width || '',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
state.current.originalBodyOverflow = document.body.style.overflow || '';
|
|
50
|
+
|
|
51
|
+
if (isBodyOverflowing) {
|
|
52
|
+
const scrollbarWidth = computeScrollbarWidth();
|
|
53
|
+
|
|
54
|
+
state.current.elements.forEach((el) => {
|
|
55
|
+
// eslint-disable-next-line no-param-reassign
|
|
56
|
+
el.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Add "overflow: hidden" to body element.
|
|
61
|
+
document.body.style.overflow = 'hidden';
|
|
62
|
+
},
|
|
63
|
+
show() {
|
|
64
|
+
state.current.counter -= 1;
|
|
65
|
+
|
|
66
|
+
if (state.current.counter !== 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Remove "overflow: hidden" from body element.
|
|
71
|
+
document.body.style.overflow = state.current.originalBodyOverflow;
|
|
72
|
+
|
|
73
|
+
// Reset body padding adjustments.
|
|
74
|
+
state.current.elements.forEach((el, key) => {
|
|
75
|
+
// eslint-disable-next-line no-param-reassign
|
|
76
|
+
el.style.width = state.current.originalWidths[key] || '';
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
[],
|
|
81
|
+
);
|
|
82
|
+
}
|