So sad that you asked 4 years ago, and I just saw it.
The problem arises because the scrollHeight property returns the entire height of the element in pixels; including registration, but not border, scroll bar or margin. (At least in Chrome, IE, and Firefox, these are the three that I tested).
Link: Element Scroll Height
So, I changed line 17 in your Jsfiddle as shown below and the problem is resolved.
var h = Math.max(e.expandMin, Math.min(e.scrollHeight - 6, e.expandMax));
source share