mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Fix scale parsing for viewport
This commit is contained in:
parent
f26b0c9f00
commit
433599e0b3
2 changed files with 31 additions and 16 deletions
|
@ -145,11 +145,6 @@
|
||||||
rendition.on("rendered", function(section){
|
rendition.on("rendered", function(section){
|
||||||
var nextSection = section.next();
|
var nextSection = section.next();
|
||||||
var prevSection = section.prev();
|
var prevSection = section.prev();
|
||||||
var current = book.navigation.get(section.href);
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
title.textContent = current.label;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nextSection) {
|
if(nextSection) {
|
||||||
next.textContent = "›";
|
next.textContent = "›";
|
||||||
|
@ -166,6 +161,12 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
rendition.on("locationChanged", function(location){
|
rendition.on("locationChanged", function(location){
|
||||||
|
var current = book.navigation.get(location.href);
|
||||||
|
|
||||||
|
if (current) {
|
||||||
|
title.textContent = current.label;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(location);
|
console.log(location);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,8 @@ class Contents {
|
||||||
}
|
}
|
||||||
|
|
||||||
viewport(options) {
|
viewport(options) {
|
||||||
var width, height, scale, scalable;
|
var _width, _height, _scale, _minimum, _maximum, _scalable;
|
||||||
|
var width, height, scale, minimum, maximum, scalable;
|
||||||
var $viewport = this.document.querySelector("meta[name='viewport']");
|
var $viewport = this.document.querySelector("meta[name='viewport']");
|
||||||
var newContent = "";
|
var newContent = "";
|
||||||
|
|
||||||
|
@ -186,18 +187,29 @@ class Contents {
|
||||||
*/
|
*/
|
||||||
if($viewport && $viewport.hasAttribute("content")) {
|
if($viewport && $viewport.hasAttribute("content")) {
|
||||||
let content = $viewport.getAttribute("content");
|
let content = $viewport.getAttribute("content");
|
||||||
let contents = content.split(/\s*,\s*/);
|
let _width = content.match(/width\s*=\s*([^,]*)/g);
|
||||||
if(contents[0]){
|
let _height = content.match(/height\s*=\s*([^,]*)/g);
|
||||||
width = contents[0].replace("width=", "").trim();
|
let _scale = content.match(/initial-scale\s*=\s*([^,]*)/g);
|
||||||
|
let _minimum = content.match(/minimum-scale\s*=\s*([^,]*)/g);
|
||||||
|
let _maximum = content.match(/maximum-scale\s*=\s*([^,]*)/g);
|
||||||
|
let _scalable = content.match(/user-scalable\s*=\s*([^,]*)/g);
|
||||||
|
if(_width[1]){
|
||||||
|
width = _width[1];
|
||||||
}
|
}
|
||||||
if(contents[1]){
|
if(_height[1]){
|
||||||
height = contents[1].replace("height=", "").trim();
|
height = _height[1];
|
||||||
}
|
}
|
||||||
if(contents[2]){
|
if(_scale[1]){
|
||||||
scale = contents[2].replace("initial-scale=", "").trim();
|
scale = _scale[1];
|
||||||
}
|
}
|
||||||
if(contents[3]){
|
if(_minimum[1]){
|
||||||
scalable = contents[3].replace("user-scalable=", "").trim();
|
minimum = _minimum[1];
|
||||||
|
}
|
||||||
|
if(_maximum[1]){
|
||||||
|
maximum = _maximum[1];
|
||||||
|
}
|
||||||
|
if(_scalable[1]){
|
||||||
|
scalable = _scalable[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +221,8 @@ class Contents {
|
||||||
newContent += ", initial-scale=" + (options.scale || scale);
|
newContent += ", initial-scale=" + (options.scale || scale);
|
||||||
}
|
}
|
||||||
if (options.scalable || scalable) {
|
if (options.scalable || scalable) {
|
||||||
|
newContent += ", minimum-scale=" + (options.scale || minimum);
|
||||||
|
newContent += ", maximum-scale=" + (options.scale || maximum);
|
||||||
newContent += ", user-scalable=" + (options.scalable || scalable);
|
newContent += ", user-scalable=" + (options.scalable || scalable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +685,7 @@ class Contents {
|
||||||
this.height(height);
|
this.height(height);
|
||||||
|
|
||||||
// Deal with Mobile trying to scale to viewport
|
// Deal with Mobile trying to scale to viewport
|
||||||
this.viewport({ width: width, height: height, scale: 1.0 });
|
this.viewport({ width: width, height: height, scale: 1.0, scalable: "no" });
|
||||||
|
|
||||||
// this.overflowY("hidden");
|
// this.overflowY("hidden");
|
||||||
this.css("overflow-y", "hidden");
|
this.css("overflow-y", "hidden");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue