File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -182,10 +182,13 @@ export default class ZoomPane {
182
182
this . isShowing = true ;
183
183
184
184
addClasses ( this . el , this . openClasses ) ;
185
- addClasses ( this . el , this . loadingClasses ) ;
186
185
187
- this . imgEl . addEventListener ( "load" , this . _handleLoad , false ) ;
188
- this . _setImageURL ( imageURL ) ;
186
+ if ( this . imgEl . getAttribute ( "src" ) != imageURL ) {
187
+ addClasses ( this . el , this . loadingClasses ) ;
188
+ this . imgEl . addEventListener ( "load" , this . _handleLoad , false ) ;
189
+ this . _setImageURL ( imageURL ) ;
190
+ }
191
+
189
192
this . _setImageSize ( triggerWidth , triggerHeight ) ;
190
193
191
194
if ( this . _isInline ) {
Original file line number Diff line number Diff line change @@ -77,4 +77,23 @@ describe("ZoomPane", () => {
77
77
78
78
expect ( zoomPane . imgEl . style . width ) . toBe ( `${ triggerWidth * zoomPane . settings . zoomFactor } px` ) ;
79
79
} ) ;
80
+
81
+ it ( "does not add the drift-loading class after first hover" , ( ) => {
82
+ const zoomPane = new ZoomPane ( zoomPaneOptions ( ) ) ;
83
+ const testSrc = "http://assets.imgix.net/unsplash/pretty2.jpg" ;
84
+ const triggerWidth = 400 ;
85
+
86
+ zoomPane . show ( testSrc , triggerWidth ) ;
87
+ expect ( zoomPane . el . classList . toString ( ) ) . toContain ( "drift-loading" ) ;
88
+
89
+ zoomPane . hide ( ) ;
90
+ setTimeout ( function ( ) {
91
+ expect ( zoomPane . el . classList . toString ( ) ) . not . toContain ( "drift-loading" ) ;
92
+ } , 1000 ) ;
93
+
94
+ zoomPane . show ( testSrc , triggerWidth ) ;
95
+ setTimeout ( function ( ) {
96
+ expect ( zoomPane . el . classList . toString ( ) ) . not . toContain ( "drift-loading" ) ;
97
+ } , 1000 ) ;
98
+ } ) ;
80
99
} ) ;
You can’t perform that action at this time.
0 commit comments