aria-voyager
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -174,5 +174,4 @@ // src/controls/-utils.ts | ||
handleFocus() { | ||
const multiSelection = this.control.capabilities.multiSelection && this.control.options.multiple; | ||
const selectionPresent = this.control.selection.length > 0; | ||
if (multiSelection && selectionPresent) { | ||
if (selectionPresent) { | ||
this.activateItem(this.control.selection[0]); | ||
@@ -348,5 +347,5 @@ } else { | ||
if (this.control.prevActiveItem && this.control.items.indexOf(this.control.prevActiveItem) < this.control.items.indexOf(item)) { | ||
this.scrollDownwardsToItem(item); | ||
} else { | ||
this.scrollUpwardsToItem(item); | ||
} else { | ||
this.scrollDownwardsToItem(item); | ||
} | ||
@@ -356,3 +355,4 @@ } | ||
if (!this.isItemInViewport(item) || item.offsetTop === 0) { | ||
this.control.element.scrollTop = item.offsetTop; | ||
const buffer = this.calcBuffer(); | ||
this.control.element.scrollTop = item.offsetTop - buffer; | ||
} | ||
@@ -362,9 +362,22 @@ } | ||
if (!this.isItemInViewport(item)) { | ||
this.control.element.scrollTop = item.offsetTop - this.control.element.clientHeight + item.clientHeight; | ||
const buffer = this.calcBuffer(); | ||
this.control.element.scrollTop = item.offsetTop - this.control.element.clientHeight + item.clientHeight + buffer; | ||
} | ||
} | ||
isItemInViewport(item) { | ||
const buffer = 2; | ||
return this.control.element.scrollTop + this.control.element.clientHeight >= item.offsetTop + buffer || this.control.element.scrollTop + buffer <= item.offsetTop + item.clientHeight; | ||
const buffer = this.calcBuffer(); | ||
const viewportLowerEdge = this.control.element.scrollTop + this.control.element.clientHeight; | ||
const itemLowerEdge = item.offsetTop + item.clientHeight + buffer; | ||
const visibleFromTop = viewportLowerEdge >= itemLowerEdge; | ||
const viewportUpperEdge = this.control.element.scrollTop; | ||
const itemUpperEdge = item.offsetTop - buffer; | ||
const visibleFromBottom = viewportUpperEdge <= itemUpperEdge; | ||
const itemIsTallerThanContainer = item.clientHeight > this.control.element.clientHeight; | ||
return visibleFromTop && visibleFromBottom && !itemIsTallerThanContainer; | ||
} | ||
calcBuffer() { | ||
const style = window.getComputedStyle(this.control.element); | ||
const padding = style.getPropertyValue("padding-block"); | ||
return Math.max(2, Number.parseFloat(padding)); | ||
} | ||
}; | ||
@@ -371,0 +384,0 @@ |
{ | ||
"name": "aria-voyager", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A framework agnostic / universal package that implements navigation patterns for various aria roles and features", | ||
@@ -23,25 +23,27 @@ "author": "gossi", | ||
"lodash.isequal": "^4.5.0", | ||
"uuid": "^9.0.1" | ||
"uuid": "^10.0.0" | ||
}, | ||
"devDependencies": { | ||
"@gossi/config-eslint": "^0.10.0", | ||
"@gossi/config-prettier": "^0.9.0", | ||
"@swc/cli": "^0.3.10", | ||
"@swc/core": "^1.4.6", | ||
"@testing-library/dom": "^10.3.1", | ||
"@types/css-modules": "^1.0.5", | ||
"@types/eslint": "^8.56.5", | ||
"@types/lodash.isequal": "^4.5.8", | ||
"@types/uuid": "^9.0.8", | ||
"@vitest/browser": "^1.6.0", | ||
"@vitest/coverage-istanbul": "^1.6.0", | ||
"@vitest/ui": "^1.6.0", | ||
"concurrently": "^8.2.2", | ||
"eslint": "^8.57.0", | ||
"prettier": "^3.2.5", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.5.2", | ||
"vite": "^5.2.11", | ||
"vitest": "^1.6.0", | ||
"webdriverio": "^8.36.1" | ||
"@gossi/config-eslint": "0.12.0", | ||
"@gossi/config-prettier": "0.9.0", | ||
"@hokulea/core": "^0.1.0", | ||
"@hokulea/theme-moana": "^0.0.2", | ||
"@swc/cli": "0.4.0", | ||
"@swc/core": "1.7.6", | ||
"@testing-library/dom": "10.4.0", | ||
"@types/css-modules": "1.0.5", | ||
"@types/eslint": "9.6.0", | ||
"@types/lodash.isequal": "4.5.8", | ||
"@types/uuid": "10.0.0", | ||
"@vitest/browser": "^2.0.5", | ||
"@vitest/coverage-istanbul": "^2.0.5", | ||
"@vitest/ui": "^2.0.5", | ||
"concurrently": "8.2.2", | ||
"eslint": "8.57.0", | ||
"prettier": "3.3.3", | ||
"tsup": "8.2.4", | ||
"typescript": "5.5.4", | ||
"vite": "5.3.5", | ||
"vitest": "^2.0.5", | ||
"webdriverio": "^8.39.1" | ||
}, | ||
@@ -51,5 +53,2 @@ "engines": { | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"scripts": { | ||
@@ -72,6 +71,5 @@ "dev": "vite", | ||
"lint:types": "tsc --noEmit", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:ui": "vitest --ui" | ||
"test": "vitest run --browser.headless --browser.provider=webdriverio", | ||
"test:ui": "vitest" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70052
1938
22
+ Addeduuid@10.0.0(transitive)
- Removeduuid@9.0.1(transitive)
Updateduuid@^10.0.0