@primer/behaviors 0.0.0-2021113211757 → 0.0.0-2021113224447
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,4 +4,4 @@ export interface ScrollIntoViewOptions {
|
|
|
4
4
|
endMargin?: number;
|
|
5
5
|
behavior?: ScrollBehavior;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare function scrollIntoView(child: HTMLElement, viewingArea: HTMLElement, { direction, startMargin, endMargin, behavior }?: ScrollIntoViewOptions): void;
|
package/dist/scroll-into-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function scrollIntoView(child, viewingArea, { direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth' } = {}) {
|
|
2
2
|
const startSide = direction === 'vertical' ? 'top' : 'left';
|
|
3
3
|
const endSide = direction === 'vertical' ? 'bottom' : 'right';
|
|
4
4
|
const scrollSide = direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
|
@@ -14,4 +14,4 @@ export const scrollIntoView = (child, viewingArea, { direction = 'vertical', sta
|
|
|
14
14
|
const scrollHeightToChildBottom = childEnd - viewingAreaEnd + viewingArea[scrollSide];
|
|
15
15
|
viewingArea.scrollTo({ behavior, [startSide]: scrollHeightToChildBottom + startMargin });
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
}
|