@@ -251,7 +251,7 @@ window._component = {
251
251
dimension ++ ;
252
252
_component . dimensional ( output , data . nodes , dimension , parentNodes ) ;
253
253
} ,
254
- imgDelay ( name , time = 200 , zoom = false ) {
254
+ imgDelay ( name , time = 200 , zoom = false , width = 300 , height = 0 ) {
255
255
let list = document . getElementsByClassName ( name ) ;
256
256
let i = 0 ;
257
257
for ( let dom of list ) {
@@ -264,12 +264,45 @@ window._component = {
264
264
dom . addEventListener ( 'mouseover' , function ( e ) {
265
265
document . body . append ( img ) ;
266
266
img . style . position = 'absolute' ;
267
- img . style . top = `${ e . pageY + 7 } px` ;
268
- img . style . left = `${ e . pageX + 7 } px` ;
269
267
img . style . zIndex = '1000000' ;
270
- img . style . width = '300px' ;
271
268
img . style . borderRadius = '3px' ;
272
269
img . setAttribute ( 'src' , src ) ;
270
+
271
+ let scale ;
272
+ if ( width === 0 ) {
273
+ scale = img . naturalWidth / img . naturalWidth ;
274
+ } else {
275
+ scale = width / img . naturalWidth ;
276
+ }
277
+ let offsetY = img . naturalHeight * scale / 2 ;
278
+ if ( height > 0 ) {
279
+ offsetY = height / 2 ;
280
+ img . style . height = `${ height } px` ;
281
+ } else if ( height < 0 ) {
282
+ if ( img . naturalHeight > window . innerHeight ) {
283
+ let h = ( window . innerHeight - 10 ) ;
284
+ img . style . height = `${ h } px` ;
285
+ offsetY = ( h ) / 2 ;
286
+ width = 0 ;
287
+ }
288
+ }
289
+ if ( width > 0 ) {
290
+ img . style . width = `${ width } px` ;
291
+ } else {
292
+ img . style . width = `auto` ;
293
+ }
294
+ img . style . top = `${ e . pageY - offsetY } px` ;
295
+ let distanceToBottom = window . innerHeight - e . clientY ;
296
+ if ( window . innerHeight - e . clientY < offsetY + 5 ) {
297
+ img . style . top = `${ e . pageY - ( offsetY + ( offsetY - distanceToBottom ) + 5 ) } px` ;
298
+ } else if ( e . clientY < offsetY - 5 ) {
299
+ img . style . top = `${ e . pageY - ( offsetY - ( offsetY - e . clientY ) - 5 ) } px` ;
300
+ }
301
+ if ( window . innerWidth - e . clientX < img . naturalWidth ) {
302
+ img . style . left = `${ e . pageX - img . naturalWidth - 30 } px` ;
303
+ } else {
304
+ img . style . left = `${ e . pageX + 25 } px` ;
305
+ }
273
306
} ) ;
274
307
dom . addEventListener ( 'mouseout' , function ( e ) {
275
308
e . stopPropagation ( ) ;
@@ -1006,8 +1039,10 @@ window.ComponentLine = class {
1006
1039
/*delay image loading*/
1007
1040
if ( val . type === 'image' ) {
1008
1041
setTimeout ( ( ) => {
1009
- let zoom = val . zoom === false ? false : true ;
1010
- _component . imgDelay ( `${ this . NAME } -${ column } -img` , 200 , zoom ) ;
1042
+ let zoom = val . zoom !== undefined ? val . zoom : true ;
1043
+ let width = val . w !== undefined ? parseInt ( val . w ) : 300 ;
1044
+ let height = val . h !== undefined ? parseInt ( val . h ) : 0 ;
1045
+ _component . imgDelay ( `${ this . NAME } -${ column } -img` , 200 , zoom , width , height ) ;
1011
1046
} ) ;
1012
1047
}
1013
1048
if ( val . type === 'datetime' || val . insert_type === 'datetime' ) {
0 commit comments