/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { coerceBooleanProperty } from '@angular/cdk/coercion'; /** * Mixin to provide a directive with a function that checks if the sticky input has been * changed since the last time the function was called. Essentially adds a dirty-check to the * sticky value. * @docs-private */ export function mixinHasStickyInput(base) { return class extends base { /** Whether sticky positioning should be applied. */ get sticky() { return this._sticky; } set sticky(v) { const prevValue = this._sticky; this._sticky = coerceBooleanProperty(v); this._hasStickyChanged = prevValue !== this._sticky; } /** Whether the sticky value has changed since this was last called. */ hasStickyChanged() { const hasStickyChanged = this._hasStickyChanged; this._hasStickyChanged = false; return hasStickyChanged; } /** Resets the dirty check for cases where the sticky state has been used without checking. */ resetStickyChanged() { this._hasStickyChanged = false; } constructor(...args) { super(...args); this._sticky = false; /** Whether the sticky input has changed since it was last checked. */ this._hasStickyChanged = false; } }; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FuLXN0aWNrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay90YWJsZS9jYW4tc3RpY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFlLHFCQUFxQixFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUE0QjFFOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLG1CQUFtQixDQUE0QixJQUFPO0lBQ3BFLE9BQU8sS0FBTSxTQUFRLElBQUk7UUFDdkIsb0RBQW9EO1FBQ3BELElBQUksTUFBTTtZQUNSLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUN0QixDQUFDO1FBQ0QsSUFBSSxNQUFNLENBQUMsQ0FBZTtZQUN4QixNQUFNLFNBQVMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDO1lBQy9CLElBQUksQ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