UNPKG

@material/linear-progress

Version:

The Material Components for the web linear progress indicator component

115 lines 4.97 kB
/** * @license * Copyright 2017 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import * as tslib_1 from "tslib"; import { getCorrectPropertyName } from '@material/animation/util'; import { MDCFoundation } from '@material/base/foundation'; import { cssClasses, strings } from './constants'; var MDCLinearProgressFoundation = /** @class */ (function (_super) { tslib_1.__extends(MDCLinearProgressFoundation, _super); function MDCLinearProgressFoundation(adapter) { return _super.call(this, tslib_1.__assign({}, MDCLinearProgressFoundation.defaultAdapter, adapter)) || this; } Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", { get: function () { return cssClasses; }, enumerable: true, configurable: true }); Object.defineProperty(MDCLinearProgressFoundation, "strings", { get: function () { return strings; }, enumerable: true, configurable: true }); Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", { get: function () { return { addClass: function () { return undefined; }, getBuffer: function () { return null; }, getPrimaryBar: function () { return null; }, hasClass: function () { return false; }, removeClass: function () { return undefined; }, setStyle: function () { return undefined; }, }; }, enumerable: true, configurable: true }); MDCLinearProgressFoundation.prototype.init = function () { this.isDeterminate_ = !this.adapter_.hasClass(cssClasses.INDETERMINATE_CLASS); this.isReversed_ = this.adapter_.hasClass(cssClasses.REVERSED_CLASS); this.progress_ = 0; }; MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) { this.isDeterminate_ = isDeterminate; if (this.isDeterminate_) { this.adapter_.removeClass(cssClasses.INDETERMINATE_CLASS); this.setScale_(this.adapter_.getPrimaryBar(), this.progress_); } else { this.adapter_.addClass(cssClasses.INDETERMINATE_CLASS); this.setScale_(this.adapter_.getPrimaryBar(), 1); this.setScale_(this.adapter_.getBuffer(), 1); } }; MDCLinearProgressFoundation.prototype.setProgress = function (value) { this.progress_ = value; if (this.isDeterminate_) { this.setScale_(this.adapter_.getPrimaryBar(), value); } }; MDCLinearProgressFoundation.prototype.setBuffer = function (value) { if (this.isDeterminate_) { this.setScale_(this.adapter_.getBuffer(), value); } }; MDCLinearProgressFoundation.prototype.setReverse = function (isReversed) { this.isReversed_ = isReversed; if (this.isReversed_) { this.adapter_.addClass(cssClasses.REVERSED_CLASS); } else { this.adapter_.removeClass(cssClasses.REVERSED_CLASS); } }; MDCLinearProgressFoundation.prototype.open = function () { this.adapter_.removeClass(cssClasses.CLOSED_CLASS); }; MDCLinearProgressFoundation.prototype.close = function () { this.adapter_.addClass(cssClasses.CLOSED_CLASS); }; MDCLinearProgressFoundation.prototype.setScale_ = function (el, scaleValue) { if (!el) { return; } var value = "scaleX(" + scaleValue + ")"; this.adapter_.setStyle(el, getCorrectPropertyName(window, 'transform'), value); }; return MDCLinearProgressFoundation; }(MDCFoundation)); export { MDCLinearProgressFoundation }; // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier. export default MDCLinearProgressFoundation; //# sourceMappingURL=foundation.js.map