aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-02-11 16:43:46 -0500
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-02-11 16:43:46 -0500
commit546540013de0a7cb647f30f1fcb513ce52048b72 (patch)
tree12b78ea0e29fba23b8557864540984daf9680942 /src/Utils.ts
parent77b7c3927c454a829d7dbb2748ad322b146265a7 (diff)
parent890337b525ea460f9986562c047135bc5ca203a6 (diff)
merging
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index c7074c3da..b6a59118a 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -191,6 +191,13 @@ export namespace Utils {
return { h: h, s: s, l: l };
}
+ export function scrollIntoView(targetY: number, targetHgt: number, scrollTop: number, contextHgt: number) {
+ if (scrollTop + contextHgt < targetY + targetHgt * 1.1) {
+ return Math.ceil(targetY + targetHgt * 1.1 - contextHgt);
+ } else if (scrollTop > targetY - targetHgt * .1) {
+ return Math.max(0, Math.floor(targetY - targetHgt * .1));
+ }
+ }
export function clamp(n: number, lower: number, upper: number) {
return Math.max(lower, Math.min(upper, n));