@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
50 lines (49 loc) • 1.75 kB
JavaScript
import BaseLayer from './baselayer';
class Layer extends BaseLayer {
constructor(id, name, order, options) {
super(id, name, order, options);
/**
* This class is a used in the state of the application, which will be accessed behind a javascript proxy.
* This means that each modification made to its properties must come from outside,
* because they have to be made through the proxy, so that the modification can be listen.
* Therefore, this class must not contain any method which is updating a value directly
* For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy
*/
Object.defineProperty(this, "activeState", {
enumerable: true,
configurable: true,
writable: true,
value: 'off'
});
Object.defineProperty(this, "opacity", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "protected", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "swiped", {
enumerable: true,
configurable: true,
writable: true,
value: 'no'
});
this.opacity = options?.opacity ?? 1;
this.protected = options?.protected ?? false;
}
get isTransparent() {
return this.opacity !== 1;
}
get active() {
return this.activeState === 'on';
}
get inactive() {
return this.activeState === 'off';
}
}
export default Layer;