UNPKG

@pilotlab/lux-tools

Version:

A luxurious user experience framework, developed by your friends at Pilot.

47 lines 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const is_1 = require("@pilotlab/is"); const signals_1 = require("@pilotlab/signals"); const rangeScale_1 = require("./rangeScale"); class RangeScaleBase { constructor(inputMin = 0, inputMax = 1, ease) { this.p_inputMin = 0.0; this.p_inputMax = 1.0; this.enteredRangeFromBelow = new signals_1.Signal(); this.enteredRangeFromAbove = new signals_1.Signal(); if (is_1.default.notEmpty(inputMin)) this.p_inputMin = inputMin; if (is_1.default.notEmpty(inputMax)) this.p_inputMax = inputMax; this.p_ease = ease; } get inputMin() { return this.p_inputMin; } set inputMin(value) { this.p_inputMin = value; } get inputMax() { return this.p_inputMax; } set inputMax(value) { this.p_inputMax = value; } get ease() { return this.p_ease; } set ease(value) { this.p_ease = value; } get progress() { return this.p_lastInputNormalized; } get p() { return this.progress; } normalizeInput(inputUnnormalized, isConstrain = true, isInvert = false) { return rangeScale_1.default.normalize(inputUnnormalized, this.p_inputMin, this.p_inputMax, isConstrain, isInvert); } unnormalizeInput(inputNormalized, isConstrain = true, isInvert = false) { return rangeScale_1.default.unnormalize(inputNormalized, this.p_inputMin, this.p_inputMax, isConstrain, isInvert); } p_checkInputPreviousRaw(inputValueRaw) { if (is_1.default.notEmpty(this.p_lastInputRaw) && (this.p_lastInputRaw < this.p_inputMin || this.p_lastInputRaw > this.p_inputMax) && (inputValueRaw >= this.p_inputMin && inputValueRaw <= this.p_inputMax)) { if (this.p_lastInputRaw < this.p_inputMin) { this.enteredRangeFromBelow.dispatch(inputValueRaw); } else if (this.p_lastInputRaw > this.p_inputMax) { this.enteredRangeFromAbove.dispatch(inputValueRaw); } } } } exports.RangeScaleBase = RangeScaleBase; exports.default = RangeScaleBase; //# sourceMappingURL=rangeScaleBase.js.map