mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
mermaid: fix broken zoom since update to v10 #608
This commit is contained in:
parent
3dada8b058
commit
e837822172
1 changed files with 17 additions and 12 deletions
|
@ -277,18 +277,23 @@ function initMermaid( update, attrs ) {
|
||||||
var is_initialized = ( update ? update_func( attrs ) : init_func( attrs ) );
|
var is_initialized = ( update ? update_func( attrs ) : init_func( attrs ) );
|
||||||
if( is_initialized ){
|
if( is_initialized ){
|
||||||
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, window.relearn.mermaidConfig, { theme: attrs.theme } ) );
|
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, window.relearn.mermaidConfig, { theme: attrs.theme } ) );
|
||||||
mermaid.run();
|
mermaid.run({
|
||||||
// zoom for Mermaid
|
postRenderCallback: function(){
|
||||||
// https://github.com/mermaid-js/mermaid/issues/1860#issuecomment-1345440607
|
// zoom for Mermaid
|
||||||
var svgs = d3.selectAll( '.mermaid.zoom svg' );
|
// https://github.com/mermaid-js/mermaid/issues/1860#issuecomment-1345440607
|
||||||
svgs.each( function(){
|
var svgs = d3.selectAll( '.mermaid.zoom svg' );
|
||||||
var svg = d3.select( this );
|
svgs.each( function(){
|
||||||
svg.html( '<g>' + svg.html() + '</g>' );
|
var svg = d3.select( this );
|
||||||
var inner = svg.select( 'g' );
|
svg.html( '<g>' + svg.html() + '</g>' );
|
||||||
var zoom = d3.zoom().on( 'zoom', function( e ){
|
var inner = svg.select( 'g' );
|
||||||
inner.attr( 'transform', e.transform);
|
var zoom = d3.zoom().on( 'zoom', function( e ){
|
||||||
});
|
inner.attr( 'transform', e.transform);
|
||||||
svg.call( zoom );
|
});
|
||||||
|
svg.call( zoom );
|
||||||
|
});
|
||||||
|
},
|
||||||
|
querySelector: '.mermaid',
|
||||||
|
suppressErrors: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if( update && search && search.length ){
|
if( update && search && search.length ){
|
||||||
|
|
Loading…
Reference in a new issue