File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,13 @@ body {
2525}
2626
2727.markmap-highlight-area {
28+ --mm-highlight-scale : 1 ;
2829 position : absolute;
2930 width : var (--mm-highlight-width );
3031 height : var (--mm-highlight-height );
3132 left : var (--mm-highlight-x );
3233 top : var (--mm-highlight-y );
3334 z-index : -1 ;
3435 background : # ff02 ;
35- transform : scale (1.2 );
36+ transform : scale (var ( --mm-highlight-scale ) );
3637}
Original file line number Diff line number Diff line change @@ -216,11 +216,14 @@ function checkHighlight() {
216216 highlightEl . remove ( ) ;
217217 } else {
218218 const rect = active . el . getBoundingClientRect ( ) ;
219+ const padding = 4 ;
220+ const { width } = active . node . state . rect ;
221+ const scale = ( width + padding * 2 ) / width ;
219222 highlightEl . setAttribute (
220223 'style' ,
221- `--mm-highlight-x:${ rect . x } px;--mm-highlight-y:${ rect . y } px;--mm-highlight-width:${ rect . width } px;--mm-highlight-height:${ rect . height } px` ,
224+ `--mm-highlight-x:${ rect . x } px;--mm-highlight-y:${ rect . y } px;--mm-highlight-width:${ rect . width } px;--mm-highlight-height:${ rect . height } px;--mm-highlight-scale: ${ scale } ` ,
222225 ) ;
223- document . body . append ( highlightEl ) ;
226+ if ( ! highlightEl . parentNode ) document . body . append ( highlightEl ) ;
224227 }
225228 requestAnimationFrame ( checkHighlight ) ;
226229}
You can’t perform that action at this time.
0 commit comments