soft-components
Version:
Simple soft flexible set of web components
79 lines (78 loc) • 1.86 kB
JavaScript
import { Component, Method, Prop, Watch } from '@stencil/core';
import { handleRayTracing } from '../../utils/ray-tracer';
export class ScRayTracer {
constructor() {
this.element = null;
}
handleEvent(e) {
handleRayTracing(e, this.element);
}
initiate() {
if (this.element) {
this.element.classList.add('ray-tracing');
window.addEventListener('mousemove', this.handleEvent.bind(this));
}
console.log('initiated');
}
async setElement(target) {
this.element = target;
}
componentWillLoad() {
this.initiate();
}
disconnectedCallback() {
window.removeEventListener('mousemove', this.handleEvent.bind(this));
}
static get is() { return "sc-ray-tracer"; }
static get encapsulation() { return "shadow"; }
static get properties() { return {
"element": {
"type": "unknown",
"mutable": true,
"complexType": {
"original": "HTMLElement",
"resolved": "HTMLElement",
"references": {
"HTMLElement": {
"location": "global"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": ""
},
"defaultValue": "null"
}
}; }
static get methods() { return {
"setElement": {
"complexType": {
"signature": "(target: HTMLElement) => Promise<void>",
"parameters": [{
"tags": [],
"text": ""
}],
"references": {
"Promise": {
"location": "global"
},
"HTMLElement": {
"location": "global"
}
},
"return": "Promise<void>"
},
"docs": {
"text": "",
"tags": []
}
}
}; }
static get watchers() { return [{
"propName": "element",
"methodName": "initiate"
}]; }
}