Problem
Each call to _moveManual in l2t-paper-slider.js attaches a new anonymous click listener to every .slider__dot element via dotElems[i].addEventListener('click', ...). Because anonymous functions cannot be removed with removeEventListener, every subsequent call (e.g. from attached's setTimeout and from _reInit's setTimeout triggered by _countSlides) stacks an additional handler on each dot. Over time this causes movePos to be called multiple times per click.
Suggested fix
Replace per-dot anonymous listeners with a single delegated listener stored on the instance, added only once:
_moveManual: function () {
var this$ = this;
var dotElems = this.$.container.querySelectorAll('.slider__dot'), i;
for (i = 0; i < dotElems.length; ++i) {
dotElems[i].setAttribute("aria-label", "Slide " + parseInt(dotElems[i].getAttribute('aria-posinset')) + " selector");
};
if (!this._dotClickListener) {
this._dotClickListener = function (e) {
var dot = e.target.closest('.slider__dot');
if (dot) this$.movePos(dot.getAttribute('aria-posinset') - 1);
};
this.$.container.addEventListener('click', this._dotClickListener);
}
if (dotElems.length) {
this._dotStyles = window.getComputedStyle(dotElems[0]);
}
},
The stored _dotClickListener reference also allows cleanup in detached.
References
Problem
Each call to
_moveManualinl2t-paper-slider.jsattaches a new anonymousclicklistener to every.slider__dotelement viadotElems[i].addEventListener('click', ...). Because anonymous functions cannot be removed withremoveEventListener, every subsequent call (e.g. fromattached'ssetTimeoutand from_reInit'ssetTimeouttriggered by_countSlides) stacks an additional handler on each dot. Over time this causesmovePosto be called multiple times per click.Suggested fix
Replace per-dot anonymous listeners with a single delegated listener stored on the instance, added only once:
The stored
_dotClickListenerreference also allows cleanup indetached.References