Readmore.js icon indicating copy to clipboard operation
Readmore.js copied to clipboard

getBoundingClientRect needs to be parsed

Open Dahkon opened this issue 6 years ago • 1 comments

I came on a bug that only occurs en chrome desktop mode, brave is ok, emulation mobile is ok too...

Here is the line on the dist file that needs to be corrected : 481 var expanded = parseInt(element.getBoundingClientRect().height) <= element.readmore.collapsedHeight;

parseInt fix the issue. Else the value returned by this function is not equal or less to collapsedHeight (240.000001453 > 240).

Hope it helps.

Dahkon avatar Jul 04 '19 18:07 Dahkon

Got the exact same issue in Chrome (98.0.4758.102), the block won't expand because of:

console.log(element.getBoundingClientRect().height, element.readmore.collapsedHeight)
// 200.00001525878906 200

Another suggestion is to take heightMargin option into account when defining var expanded on line 481:

var expanded = element.getBoundingClientRect().height <= element.readmore.collapsedHeight + element.readmore.heightMargin;

zakutnya avatar Feb 17 '22 09:02 zakutnya