Skip to content

Commit

Permalink
mermaid: reset zoom correctly #690
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Oct 18, 2023
1 parent 76eeaa5 commit 292e261
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions static/js/theme.js
Expand Up @@ -318,7 +318,7 @@ function initMermaid( update, attrs ) {
svgs.each( function(){
var svg = d3.select( this );
svg.html( '<g>' + svg.html() + '</g>' );
var inner = svg.select( 'g' );
var inner = svg.select( '*:scope > g' );
var zoom = d3.zoom().on( 'zoom', function( e ){
inner.attr( 'transform', e.transform );
});
Expand All @@ -331,7 +331,7 @@ function initMermaid( update, attrs ) {
parent.insertAdjacentHTML( 'beforeend', '<span class="svg-reset-button" title="' + window.T_Reset_view + '"><i class="fas fa-undo-alt"></i></span>' );
var button = parent.querySelector( '.svg-reset-button' );
button.addEventListener( 'click', function( event ){
inner.transition()
svg.transition()
.duration( 350 )
.call( zoom.transform, d3.zoomIdentity );
this.setAttribute( 'aria-label', window.T_View_reset );
Expand Down

0 comments on commit 292e261

Please sign in to comment.