@@ -4,14 +4,19 @@ export default {
4
4
props : {
5
5
open : {
6
6
type : Boolean ,
7
- default : false
7
+ default : false ,
8
8
} ,
9
-
9
+
10
10
images : {
11
11
type : Array ,
12
12
required : true ,
13
13
} ,
14
14
15
+ disableScroll : {
16
+ type : Boolean ,
17
+ default : true ,
18
+ } ,
19
+
15
20
showLightBox : {
16
21
type : Boolean ,
17
22
default : true ,
@@ -34,7 +39,7 @@ export default {
34
39
35
40
// Mode
36
41
autoPlay : {
37
- type : Boolean ,
42
+ type : Boolean ,
38
43
default : false ,
39
44
} ,
40
45
@@ -60,26 +65,25 @@ export default {
60
65
lightBoxOn : this . showLightBox ,
61
66
displayThumbs : this . images . slice ( 0 , this . nThumbs ) ,
62
67
timer : null ,
63
-
64
68
beginThumbIndex : 0 ,
65
69
}
66
70
} ,
67
71
68
72
computed : {
69
- countImages ( ) {
73
+ countImages ( ) {
70
74
return this . images . length
71
75
} ,
72
76
73
- imagesThumb ( ) {
77
+ imagesThumb ( ) {
74
78
if ( this . siteLoading ) {
75
- return this . displayThumbs . map ( ( { thumb } ) => ( {
79
+ return this . displayThumbs . map ( ( { thumb} ) => ( {
76
80
src : thumb ,
77
81
loading : this . siteLoading ,
78
- error : this . siteLoading ,
82
+ error : this . siteLoading
79
83
} ) )
80
84
}
81
85
82
- return this . displayThumbs . map ( ( { thumb } ) => thumb )
86
+ return this . displayThumbs . map ( ( { thumb} ) => thumb )
83
87
} ,
84
88
} ,
85
89
@@ -119,19 +123,25 @@ export default {
119
123
lightBoxOn ( value ) {
120
124
if ( document != null ) {
121
125
if ( value ) {
126
+ if ( this . disableScroll ) {
127
+ document . getElementsByTagName ( 'html' ) [ 0 ] . classList . add ( 'no-scroll' )
128
+ }
122
129
document . getElementsByTagName ( 'body' ) [ 0 ] . classList . add ( 'vue-lb-open' )
123
130
this . $emit ( 'lightBoxOn' , true )
124
131
} else {
132
+ if ( this . disableScroll ) {
133
+ document . getElementsByTagName ( 'html' ) [ 0 ] . classList . remove ( 'no-scroll' )
134
+ }
125
135
document . getElementsByTagName ( 'body' ) [ 0 ] . classList . remove ( 'vue-lb-open' )
126
136
this . $emit ( 'lightBoxOn' , false )
127
137
}
128
- }
138
+ }
129
139
} ,
130
-
140
+
131
141
open ( value ) {
132
142
if ( value ) {
133
- this . openLightBox ( ) ;
134
- this . $emit ( 'opened' ) ;
143
+ this . openLightBox ( )
144
+ this . $emit ( 'opened' )
135
145
}
136
146
} ,
137
147
} ,
@@ -147,7 +157,6 @@ export default {
147
157
methods : {
148
158
showImage ( index ) {
149
159
document . addEventListener ( 'keydown' , this . addKeyEvent )
150
-
151
160
this . $set ( this , 'lightBoxOn' , true )
152
161
this . $set ( this , 'select' , index )
153
162
} ,
@@ -162,9 +171,9 @@ export default {
162
171
this . $set ( this , 'lightBoxOn' , false )
163
172
document . removeEventListener ( 'keydown' , this . addKeyEvent )
164
173
} ,
165
-
174
+
166
175
openLightBox ( ) {
167
- this . showImage ( this . beginThumbIndex ) ;
176
+ this . showImage ( this . beginThumbIndex )
168
177
} ,
169
178
170
179
nextImage ( ) {
@@ -176,7 +185,6 @@ export default {
176
185
} ,
177
186
} ,
178
187
179
-
180
188
beforeDestroy ( ) {
181
189
document . removeEventListener ( 'keydown' , this . addKeyEvent )
182
190
0 commit comments