UNPKG

@itk-viewer/element

Version:
69 lines (68 loc) 2.44 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { LitElement, css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { ref } from 'lit/directives/ref.js'; import { SelectorController } from 'xstate-lit'; import { createLogic } from '@itk-viewer/vtkjs/view-2d-vtkjs.js'; import { dispatchSpawn } from './spawn-controller.js'; import './itk-camera.js'; let ItkView2dVtkjs = class ItkView2dVtkjs extends LitElement { constructor() { super(...arguments); this.dispatched = false; } getActor() { return this.actor; } setActor(actor) { this.actor = actor; this.sendContainer(); this.cameraActor = new SelectorController(this, this.actor, (state) => state.context.camera); } sendContainer() { if (!this.actor) return; this.actor.send({ type: 'setContainer', container: this.container }); } onContainer(container) { if (container instanceof HTMLElement || container == undefined) { this.container = container; this.sendContainer(); } } render() { if (!this.dispatched) { dispatchSpawn(this, 'renderer', createLogic(), (actor) => this.setActor(actor)); this.dispatched = true; } return html ` <itk-camera .actor=${this.cameraActor?.value} class="container"> <div class="container" ${ref(this.onContainer)}></div> </itk-camera> `; } static { this.styles = css ` :host { flex: 1; display: flex; flex-direction: column; } .container { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; } `; } }; ItkView2dVtkjs = __decorate([ customElement('itk-view-2d-vtkjs') ], ItkView2dVtkjs); export { ItkView2dVtkjs }; //# sourceMappingURL=itk-view-2d-vtkjs.js.map