makeup-active-descendant
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -20,2 +20,6 @@ "use strict"; | ||
}; | ||
function isElementInView(el) { | ||
const bounding = el.getBoundingClientRect(); | ||
return bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth); | ||
} | ||
function onModelInit(e) { | ||
@@ -48,5 +52,6 @@ const { | ||
this._focusEl.setAttribute("aria-activedescendant", toItem.id); | ||
if (this._options.autoScroll && this._itemContainerEl) { | ||
if (this._options.autoScroll && this._itemContainerEl && !isElementInView(toItem)) { | ||
toItem.scrollIntoView({ | ||
block: "center" | ||
behavior: "smooth", | ||
block: "nearest" | ||
}); | ||
@@ -53,0 +58,0 @@ } |
@@ -11,2 +11,6 @@ import * as NavigationEmitter from "makeup-navigation-emitter"; | ||
}; | ||
function isElementInView(el) { | ||
const bounding = el.getBoundingClientRect(); | ||
return bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth); | ||
} | ||
function onModelInit(e) { | ||
@@ -31,4 +35,4 @@ const { items, toIndex } = e.detail; | ||
this._focusEl.setAttribute("aria-activedescendant", toItem.id); | ||
if (this._options.autoScroll && this._itemContainerEl) { | ||
toItem.scrollIntoView({ block: "center" }); | ||
if (this._options.autoScroll && this._itemContainerEl && !isElementInView(toItem)) { | ||
toItem.scrollIntoView({ behavior: "smooth", block: "nearest" }); | ||
} | ||
@@ -35,0 +39,0 @@ } |
{ | ||
"name": "makeup-active-descendant", | ||
"description": "Implements ARIA active descendant keyboard navigation", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"main": "./dist/cjs/index.js", | ||
@@ -41,3 +41,3 @@ "module": "./dist/mjs/index.js", | ||
], | ||
"gitHead": "72b3adbcb4d841dbd4ad8e722637b3d7de3ab7f0" | ||
"gitHead": "66ba8f5998b1d9364dc4c8cc56663e8e517ed289" | ||
} |
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21258
309
1
1