1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Update display to accept percentages, handle getting location of collapsed ranges

This commit is contained in:
Fred Chasen 2016-11-23 20:47:07 +01:00
parent db798e7934
commit fb04ac2c25
10 changed files with 390 additions and 204 deletions

View file

@ -388,7 +388,13 @@ Contents.prototype.locationOf = function(target, ignoreClass) {
targetPos.left = position.left;
targetPos.top = position.top;
} else {
position = range.getBoundingClientRect();
// Webkit does not handle collapsed range bounds correctly
// https://bugs.webkit.org/show_bug.cgi?id=138949
if (range.collapsed) {
position = range.getClientRects()[0];
} else {
position = range.getBoundingClientRect();
}
targetPos.left = position.left;
targetPos.top = position.top;
}