-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: corrected scrollbar styles to have proper spacing
- Loading branch information
1 parent
2ea3164
commit 0146978
Showing
8 changed files
with
146 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
height: 20px; | ||
padding: 3px 7px; | ||
margin-bottom: 7px; | ||
border-radius: 4px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { Action } from "svelte/action"; | ||
import { writable } from "svelte/store"; | ||
|
||
type IsOverflowingParams = { | ||
callback: (isOverflowing: boolean) => void; | ||
} | ||
|
||
/** | ||
* A Svelte directive for detecting when an element is overflowing.. | ||
*/ | ||
export const isOverflowing: Action<HTMLElement, IsOverflowingParams | undefined> = (node: HTMLElement, props = { callback: (isOverflowing: boolean) => {} }) => { | ||
let callback = props.callback; | ||
|
||
const isOverflowing = writable(false); | ||
const isOverflowingUnsub = isOverflowing.subscribe((isOverflowing: boolean) => { | ||
callback(isOverflowing); | ||
}); | ||
|
||
const observer = new ResizeObserver((entries: ResizeObserverEntry[]) => { | ||
const element = entries[0].target; | ||
|
||
const overflowingTop = element.scrollTop !== 0; | ||
const overflowingBottom = Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) > 0; | ||
isOverflowing.set(overflowingTop || overflowingBottom); | ||
}); | ||
|
||
node.addEventListener("scroll", scrollHandler); | ||
observer.observe(node); | ||
|
||
|
||
function scrollHandler(e: Event) { | ||
const element = e.currentTarget as HTMLDivElement; | ||
|
||
const overflowingTop = element.scrollTop !== 0; | ||
const overflowingBottom = Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) > 0; | ||
isOverflowing.set(overflowingTop || overflowingBottom); | ||
} | ||
|
||
return { | ||
update(props = { callback: (isOverflowing: boolean) => {} }) { | ||
callback = props.callback; | ||
}, | ||
destroy() { | ||
node.removeEventListener("scroll", scrollHandler); | ||
observer.disconnect(); | ||
|
||
isOverflowingUnsub(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./IsOverflowing"; | ||
export * from "./ScrollShadow"; | ||
|