From 225c5a1a0b9f93018c063cea7da2af03dec6dc6e Mon Sep 17 00:00:00 2001 From: Alexandre Moore Date: Mon, 14 May 2018 09:41:43 -0400 Subject: [PATCH] fix: fix bug when scrollHeight is slightly higher than clientHeight --- src/clampy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clampy.ts b/src/clampy.ts index beb18bf..00b422e 100644 --- a/src/clampy.ts +++ b/src/clampy.ts @@ -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 } /**