Skip to content

Commit

Permalink
fix: fix bug when scrollHeight is slightly higher than clientHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandremoore committed May 14, 2018
1 parent 7ce42e3 commit 225c5a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/clampy.ts
Expand Up @@ -130,9 +130,9 @@ export function clamp(element: HTMLElement, options?: ClampOptions): ClampRespon
* Note: inline elements return 0 for scrollHeight and clientHeight
*/
function getElemHeight(elem: HTMLElement): number {
// The '- 1' is a hack to deal with the element height when the browser(especially IE) zoom level is not 100%.
// The '- 4' is a hack to deal with the element height when the browser(especially IE) zoom level is not 100%.
// It also doesn't impact clamping when the browser zoom level is 100%.
return Math.max(elem.scrollHeight, elem.clientHeight) - 1
return Math.max(elem.scrollHeight, elem.clientHeight) - 4
}

/**
Expand Down

0 comments on commit 225c5a1

Please sign in to comment.