File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
packages/plugin-image-viewer/src Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 55 right : 0 ;
66 bottom : 0 ;
77 z-index : 10000 ;
8- background-color : rgba (0 , 0 , 0 , 0.7 );
8+ background-color : rgba (0 , 0 , 0 , 0.8 );
9+ transition : opacity 200ms ;
910}
1011.image-viewer img {
1112 position : absolute;
Original file line number Diff line number Diff line change @@ -37,14 +37,22 @@ export default function imageViewer(): BytemdPlugin {
3737 img . style . left = `${ left } px` ;
3838 img . style . top = `${ top } px` ;
3939
40- const container = document . createElement ( 'div' ) ;
41- container . className = 'image-viewer' ;
42- container . appendChild ( img ) ;
40+ const box = document . createElement ( 'div' ) ;
41+ box . className = 'image-viewer' ;
42+ box . style . opacity = '0' ;
43+ box . appendChild ( img ) ;
4344
44- document . body . appendChild ( container ) ;
45+ document . body . appendChild ( box ) ;
4546
46- container . addEventListener ( 'click' , ( e ) => {
47- document . body . removeChild ( container ) ;
47+ setTimeout ( ( ) => {
48+ box . style . opacity = '1' ;
49+ } ) ;
50+
51+ box . addEventListener ( 'click' , ( e ) => {
52+ box . addEventListener ( 'transitionend' , ( ) => {
53+ document . body . removeChild ( box ) ;
54+ } ) ;
55+ box . style . opacity = '0' ;
4856 } ) ;
4957 } ;
5058
You can’t perform that action at this time.
0 commit comments