Skip to content

Commit

Permalink
Best navigation with keyboard arrows
Browse files Browse the repository at this point in the history
Remove the height line
Zefling committed Sep 15, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5f8ed24 commit e137fac
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/common.ts
Original file line number Diff line number Diff line change
@@ -21,8 +21,6 @@ export type Select2Data = (Select2Group | Select2Option)[];

export const timeout = 200;

const height = 28;

const unicodePatterns: { l: string, s: RegExp }[] = [
{ l: "a", s: /[àáâãāăȧǡäǟåǻǎȁȃąɐ]/gi },
{ l: "aa", s: //gi },
@@ -248,14 +246,14 @@ export function getLastScrollTopIndex(
return 0;
} else {
const scrollTop = getScrollUpIndex(filteredData, hoveringValue);
if (scrollTop - lastScrollTopIndex > 6) {
lastScrollTopIndex += scrollTop - lastScrollTopIndex - 6;
results.scrollTop = lastScrollTopIndex * height;
if (scrollTop - lastScrollTopIndex > 5) {
lastScrollTopIndex += scrollTop - lastScrollTopIndex - 5;
results.scrollTop = results.querySelectorAll("li").item(scrollTop).offsetTop - results.offsetHeight;
return lastScrollTopIndex;
}
if (lastScrollTopIndex - scrollTop > 0) {
lastScrollTopIndex -= lastScrollTopIndex - scrollTop;
results.scrollTop = lastScrollTopIndex * height;
results.scrollTop = results.querySelectorAll("li").item(lastScrollTopIndex - 1).offsetTop;
return lastScrollTopIndex;
}
return null;

0 comments on commit e137fac

Please sign in to comment.