Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

feat(iron-autogrow-textarea.html): add debounce function #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion iron-autogrow-textarea.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@
}

this.bindValue = value;
this.$.mirror.innerHTML = this._valueForMirror();
this.debounce('delayMirror', function() {
this.$.mirror.innerHTML = this._valueForMirror();
}.bind(this), 500);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use no wait at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try without the wait, to see if it works.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not work without the wait. I've obtain similar results that without the debounce function.

captura de pantalla 2018-03-29 a las 9 44 20

captura de pantalla 2018-03-29 a las 9 33 27

I've also tested different values of waiting, but with 500 I've obtain better results and the delay on typing desappear:

captura de pantalla 2018-03-29 a las 9 45 42

My scenery is like a chat (made with components): a user enters in a room from a list on the left, and starts typing messages. The most number of rooms you have on the left, the greater delay you feel.

In my case, the bottleneck is this line:

this.$.mirror.innerHTML = this._valueForMirror();

Maybe this line can be made in a different way and so the debounce would not be necessary.


// Manually notify because we don't want to notify until after setting value.
this.fire('bind-value-changed', {value: this.bindValue});
Expand Down