11import { LitElement , html , css } from 'lit' ;
22import { instance } from '@viz-js/viz' ;
3+ import Panzoom from '@panzoom/panzoom' ;
34
45export class QuiDot extends LitElement {
56 static properties = {
6- dot : { type : String }
7+ dot : { type : String } ,
8+ enablePanZoom : { type : String } ,
79 } ;
810
911 static styles = css `
@@ -19,6 +21,7 @@ export class QuiDot extends LitElement {
1921 constructor ( ) {
2022 super ( ) ;
2123 this . dot = '' ;
24+ this . enablePanZoom = 'true' ;
2225 this . _viz = null ;
2326 }
2427
@@ -28,7 +31,7 @@ export class QuiDot extends LitElement {
2831 }
2932
3033 updated ( changedProps ) {
31- if ( changedProps . has ( 'dot' ) && this . _viz ) {
34+ if ( ( changedProps . has ( 'dot' ) || changedProps . has ( 'enablePanZoom' ) ) && this . _viz ) {
3235 this . _renderGraph ( ) ;
3336 }
3437 }
@@ -37,9 +40,15 @@ export class QuiDot extends LitElement {
3740 try {
3841 const svg = await this . _viz . renderSVGElement ( this . dot ) ;
3942 this . shadowRoot . innerHTML = '' ;
40- this . shadowRoot . appendChild ( svg ) ;
43+ const container = document . createElement ( 'div' )
44+ container . appendChild ( svg ) ;
45+ this . shadowRoot . appendChild ( container ) ;
46+ if ( this . enablePanZoom === 'true' ) {
47+ const panzoom = Panzoom ( svg ) ;
48+ container . addEventListener ( 'wheel' , panzoom . zoomWithWheel )
49+ }
4150 } catch ( error ) {
42- this . shadowRoot . innerHTML = `<pre style=" color:red;" >${ error } </pre>` ;
51+ this . shadowRoot . innerHTML = `<pre style=' color:red;' >${ error } </pre>` ;
4352 }
4453 }
4554
0 commit comments