Skip to content

Commit

Permalink
fix: removed upward scroll fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
meenakshi-deriv committed Jul 18, 2024
1 parent 873d242 commit ab64694
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/javascript/app/pages/trade/markets/markets-dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,16 @@ export const MarketsDropdown = () => {
const container = itemsContainer.current;

const checkActiveMarket = () => {
const marketDivs = container.querySelectorAll('div[data-id]');
const marketDivs = container.querySelectorAll('div');
let closestMarket = '';
let closestOffset = Infinity;

marketDivs.forEach((div) => {
const containerMiddle = container.scrollTop + container.clientHeight / 2;

const distanceToMiddle = Math.abs((div.offsetTop + div.offsetHeight / 2) - containerMiddle);

if (distanceToMiddle < closestOffset) {
closestOffset = distanceToMiddle;
const paddingOffset = 120;
const offsetTop = div.offsetTop - container.scrollTop - paddingOffset;

if (offsetTop <= 0 && Math.abs(offsetTop) < Math.abs(closestOffset)) {
closestOffset = offsetTop;
closestMarket = div.getAttribute('data-id');
}
});
Expand Down

0 comments on commit ab64694

Please sign in to comment.