From f54a81f7f401e72cb2a75177f0fe2235fd6b6417 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 18 Dec 2017 12:17:35 +0000 Subject: [PATCH] Resolve janky scrolling --- src/scripts/src/choices.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scripts/src/choices.js b/src/scripts/src/choices.js index d0c9dae..35ffb95 100644 --- a/src/scripts/src/choices.js +++ b/src/scripts/src/choices.js @@ -1437,7 +1437,7 @@ class Choices { if (nextEl) { // We prevent default to stop the cursor moving // when pressing the arrow - if (!isScrolledIntoView(nextEl, this.choiceList, directionInt)) { + if (!isScrolledIntoView(nextEl, this.choiceList.element, directionInt)) { this._scrollToChoice(nextEl, directionInt); } this._highlightChoice(nextEl); @@ -1773,20 +1773,20 @@ class Choices { return; } - const dropdownHeight = this.choiceList.height; + const dropdownHeight = this.choiceList.element.offsetHeight; const choiceHeight = choice.offsetHeight; // Distance from bottom of element to top of parent const choicePos = choice.offsetTop + choiceHeight; // Scroll position of dropdown - const containerScrollPos = this.choiceList.scrollPos + dropdownHeight; + const containerScrollPos = this.choiceList.element.scrollTop + dropdownHeight; // Difference between the choice and scroll position const endPoint = direction > 0 ? ( - (this.choiceList.scrollPos + choicePos) - containerScrollPos) : - choice.offsetTop; + (this.choiceList.element.scrollTop + choicePos) - containerScrollPos + ) : choice.offsetTop; const animateScroll = () => { const strength = SCROLLING_SPEED; - const choiceListScrollTop = this.choiceList.scrollPos; + const choiceListScrollTop = this.choiceList.element.scrollTop; let continueAnimation = false; let easing; let distance;