Skip to content

Commit 4c5e056

Browse files
authored
Merge pull request #157 from OneNoteDev/bug/null-check
Add a null check for the element.
2 parents e1e1842 + ce9fc7e commit 4c5e056

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/scripts/domParsers/domUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,10 @@ export module DomUtils {
944944
}
945945

946946
export function getScrollPercent(elem: Element, asDecimalValue = false) {
947+
if (!elem) {
948+
return 0;
949+
}
950+
947951
let scrollValue: number = (elem.scrollTop * 1.0) / (elem.scrollHeight - elem.clientHeight);
948952

949953
// console.warn(elem.scrollTop, elem.scrollHeight, elem.clientHeight, scrollValue);

0 commit comments

Comments
 (0)