From ba6e8c8c0eb3133542f511db28fa7ad2902bff0c Mon Sep 17 00:00:00 2001 From: Iain Reid Date: Tue, 4 Apr 2017 12:29:35 +0100 Subject: [PATCH] Fixes #105 This adds an optional 'debounceUpdate' parameter to the element to reduce spammy updates from the User in cases where a delayed update would be preferable. --- iron-input.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/iron-input.html b/iron-input.html index ddb5277..f656bb3 100644 --- a/iron-input.html +++ b/iron-input.html @@ -91,6 +91,14 @@ observer: "_allowedPatternChanged" }, + /** + * Delay the updating of the bound value whilst the user is entering data. This property will accept a number as + * its input, which should be the number of milliseconds from which the users input should be debounced. + */ + debounceUpdate: { + type: Number + }, + _previousValidInput: { type: String, value: '' @@ -199,6 +207,15 @@ } } + // If a `debounceUpdate` value has been supplied, delay the updating of the `bindValue` property + if (this.debounceUpdate) { + this.debounce('debouncedUpdateValue', this._updateValue.bind(this), this.debounceUpdate); + } else { + this._updateValue(); + } + }, + + _updateValue: function() { this.bindValue = this.value; this._previousValidInput = this.value; this._patternAlreadyChecked = false;