diff --git a/src/scripts/canvas.js b/src/scripts/canvas.js index 0527163..5b7caad 100644 --- a/src/scripts/canvas.js +++ b/src/scripts/canvas.js @@ -1,14 +1,29 @@ /* eslint-disable */ +import inView from 'in-view'; + class Canvas { constructor() { - this.connect = new CABLES.Patch({ + this.initConnectCanvas(); + this.initKleinCanvas(); + } + + initConnectCanvas() { + const connect = new CABLES.Patch({ patchFile: 'assets/connect.json', prefixAssetPath: '', glCanvasId: 'connect', glCanvasResizeToWindow: true, - silent: true + silent: true, }); + connect.pause(); + + inView.offset(0); + inView('.team').on('enter', () => connect.resume()); + inView('.team').on('exit', () => connect.pause()); + } + + initKleinCanvas() { CABLES.EMBED.addPatch( 'klein', { @@ -17,9 +32,14 @@ class Canvas { silent: true } ) + + CABLES.patch.pause(); + + inView('.hero').on('enter', () => CABLES.patch.resume()); + inView('.hero').on('exit', () => CABLES.patch.pause()); } } export default function init() { new Canvas(); -}; +}