This repository was archived by the owner on Jan 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +79
-84
lines changed Expand file tree Collapse file tree 8 files changed +79
-84
lines changed Original file line number Diff line number Diff line change 23
23
"vue" : " ^3.0.5"
24
24
},
25
25
"devDependencies" : {
26
+ "@types/body-scroll-lock" : " ^2.6.2" ,
26
27
"@types/node" : " ^16.3.1" ,
27
28
"@vitejs/plugin-vue" : " ^1.2.4" ,
28
29
"@vue/compiler-sfc" : " ^3.0.5" ,
Original file line number Diff line number Diff line change @@ -35,11 +35,10 @@ export const useStackable: (param: IUseStackableParams) => {activeZIndex: Comput
35
35
const index = isActive . value ? getMaxZIndex ( ) + 2 : getZIndex ( content . value ) ;
36
36
37
37
if ( index === null ) {
38
- // return null;
39
38
return 0
40
39
}
41
40
42
- return parseInt ( index ) ;
41
+ return index ;
43
42
} ) ;
44
43
45
44
return {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /**
2
+ *
3
+ * @param {string | number | null | undefined } str
4
+ * @param {string } unit
5
+ * @returns {string | undefined }
6
+ */
7
+ export const convertToUnit = ( str : string | number | null | undefined , unit = 'px' ) => {
8
+ if ( str == null || str === '' ) {
9
+ return undefined ;
10
+ } else if ( isNaN ( + str ) ) {
11
+ return String ( str ) ;
12
+ } else {
13
+ return `${ Number ( str ) } ${ unit } ` ;
14
+ }
15
+ } ;
16
+
17
+ export const getZIndex = ( el ?: Element ) : number => {
18
+ if ( ! el || el . nodeType !== Node . ELEMENT_NODE ) return 0 ;
19
+
20
+ const index = parseInt ( window . getComputedStyle ( el ) . getPropertyValue ( 'z-index' ) ) ;
21
+
22
+ if ( ! index ) return getZIndex ( el . parentNode as HTMLElement ) ;
23
+
24
+ return index ;
25
+ } ;
26
+
27
+ export default {
28
+ convertToUnit,
29
+ getZIndex,
30
+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { enableBodyScroll , disableBodyScroll } from 'body-scroll-lock' ;
2
+
3
+ export const getScrollbarWidth = ( ) => {
4
+ const container = document . createElement ( 'div' ) ;
5
+ container . style . visibility = 'hidden' ;
6
+ container . style . overflow = 'scroll' ;
7
+ const inner = document . createElement ( 'div' ) ;
8
+
9
+ container . appendChild ( inner ) ;
10
+ document . body . appendChild ( container ) ;
11
+ const scrollbarWidth = container . offsetWidth - inner . offsetWidth ;
12
+ document . body . removeChild ( container ) ;
13
+
14
+ return scrollbarWidth ;
15
+ } ;
16
+
17
+ /**
18
+ *
19
+ * @param {boolean } hideScroll
20
+ */
21
+ const disableScroll = ( hideScroll = false ) => {
22
+ if ( hideScroll ) {
23
+ const scrollWidth = getScrollbarWidth ( ) ;
24
+ disableBodyScroll ( document . body ) ;
25
+ if ( scrollWidth > 0 ) {
26
+ document . body . style . paddingRight = scrollWidth + 'px' ;
27
+ }
28
+ } else {
29
+ disableBodyScroll ( document . body ) ;
30
+ }
31
+ } ;
32
+
33
+ const enableScroll = ( ) => {
34
+ enableBodyScroll ( document . body ) ;
35
+ document . body . style . paddingRight = '0' ;
36
+ } ;
37
+
38
+ export default {
39
+ getScrollbarWidth,
40
+ disableScroll,
41
+ enableScroll,
42
+ } ;
Original file line number Diff line number Diff line change 20
20
" @babel/helper-validator-identifier" " ^7.14.5"
21
21
to-fast-properties "^2.0.0"
22
22
23
+ " @types/body-scroll-lock@^2.6.2 " :
24
+ version "2.6.2"
25
+ resolved "https://registry.yarnpkg.com/@types/body-scroll-lock/-/body-scroll-lock-2.6.2.tgz#ce56d17e1bf8383c08a074733c4e9e536a59ae61"
26
+ integrity sha512-PhoQPbwPYspXqf7lkwtF7aJzAwL88t+9E/e0b2X84tlHpU8ZuS9UNnLtkT0XhyZJYHpET5qRfIdZ0HBIxuc7HQ==
27
+
23
28
" @types/estree@^0.0.48 " :
24
29
version "0.0.48"
25
30
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.48.tgz#18dc8091b285df90db2f25aa7d906cfc394b7f74"
You can’t perform that action at this time.
0 commit comments