diff --git a/src/rendition.js b/src/rendition.js index 05f4494..fb3e705 100644 --- a/src/rendition.js +++ b/src/rendition.js @@ -306,10 +306,7 @@ class Rendition { this.displaying = displaying; // Check if this is a book percentage - if (this.book.locations.length() && - (isFloat(target) || - (target === "1.0")) // Handle 1.0 - ) { + if (this.book.locations.length() && isFloat(target)) { target = this.book.locations.cfiFromPercentage(parseFloat(target)); } diff --git a/src/utils/core.js b/src/utils/core.js index 749f22d..1be0fed 100644 --- a/src/utils/core.js +++ b/src/utils/core.js @@ -69,7 +69,16 @@ export function isNumber(n) { */ export function isFloat(n) { let f = parseFloat(n); - return f === n && isNumber(n) && (Math.floor(f) !== n); + + if (isNumber(n) === false) { + return false; + } + + if (typeof n === "string" && n.indexOf(".") > -1) { + return true; + } + + return Math.floor(f) !== f; } /**