UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

48 lines (47 loc) 1.35 kB
import { ComponentSystem } from "../system.js"; import { ScrollbarComponent } from "./component.js"; const _properties = ["orientation", "value", "handleSize", "handleEntity"]; class ScrollbarComponentSystem extends ComponentSystem { /** * Create a new ScrollbarComponentSystem. * * @param {AppBase} app - The application. * @ignore */ constructor(app) { super(app); this.id = "scrollbar"; this.ComponentType = ScrollbarComponent; this.on("add", this._onAddComponent, this); this.on("beforeremove", this.onBeforeRemove, this); } initializeComponentData(component, data, properties) { for (let i = 0; i < _properties.length; i++) { const property = _properties[i]; if (data.hasOwnProperty(property)) { component[property] = data[property]; } } super.initializeComponentData(component, data); } cloneComponent(entity, clone) { const c = entity.scrollbar; const data = { enabled: c.enabled }; for (let i = 0; i < _properties.length; i++) { const property = _properties[i]; data[property] = c[property]; } return this.addComponent(clone, data); } _onAddComponent(entity) { entity.fire("scrollbar:add"); } onBeforeRemove(entity, component) { component.onBeforeRemove(); } } export { ScrollbarComponentSystem };