@@ -6,7 +6,7 @@ var bgColor,
6
6
opacity ,
7
7
$blocking = $ ( '<div class="js-blocking" id="lightbox-blocking"></div>' ) ,
8
8
$body = $ ( document . body ) ,
9
- $ template = $ ( `
9
+ template = `
10
10
<div class="js-lightbox-wrap" id="lightbox-wrap">
11
11
<div class="js-lightbox-inner-wrap" id="lightbox-inner-wrap">
12
12
<div class="js-img-wrap" id="lightbox-img-wrap">
@@ -32,7 +32,7 @@ var bgColor,
32
32
</div>
33
33
</div>
34
34
</div>
35
- ` ) ,
35
+ ` ,
36
36
images = [ ] ,
37
37
active = false ,
38
38
loading = false ,
@@ -44,7 +44,7 @@ var bgColor,
44
44
var LightboxImage = function ( src , id ) {
45
45
this . src = src ;
46
46
this . id = id ;
47
- this . $view = $template . hide ( ) ;
47
+ this . $view = $ ( template ) . hide ( ) ;
48
48
49
49
var self = this ;
50
50
@@ -76,6 +76,8 @@ var LightboxImage = function(src, id) {
76
76
self . $view . css ( 'top' , top ) ;
77
77
self . $view . find ( '.js-img-wrap' ) . height ( $loadedImg . height ( ) ) ;
78
78
}
79
+
80
+ _setCloseIconColor ( self . $view , bgColor ) ;
79
81
} ;
80
82
81
83
this . render = function ( ) {
@@ -173,11 +175,16 @@ function bind() {
173
175
} ) ;
174
176
}
175
177
176
- function _setCloseIconColor ( bgColor ) {
178
+ function _setCloseIconColor ( $context , bgColor ) {
177
179
var tinyBgColor = tinycolor ( bgColor ) ;
178
180
var closeIconColor = tinyBgColor . isLight ( ) ? '#000' : '#FFF' ;
181
+ var $svg = $context . find ( '.js-close svg' ) ;
179
182
180
- $template . find ( '.js-close svg' ) . attr ( 'fill' , closeIconColor ) ;
183
+ if ( $svg . attr ( 'fill' ) ) {
184
+ return ;
185
+ }
186
+
187
+ $svg . attr ( 'fill' , closeIconColor ) ;
181
188
}
182
189
183
190
function init ( options ) {
@@ -192,8 +199,6 @@ function init(options) {
192
199
bgColor = config . bgColor ;
193
200
opacity = config . opacity ;
194
201
195
- _setCloseIconColor ( bgColor ) ;
196
-
197
202
$context . find ( '.js-lightbox' ) . each ( function ( i , el ) {
198
203
var $img = $ ( el ) ;
199
204
$img . data ( 'img-id' , i ) . addClass ( 'lightbox-link' ) ;
0 commit comments