mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Preserve aspect ratio when expanding
This commit is contained in:
parent
27fec5a305
commit
4a7e08c49a
4 changed files with 18 additions and 14 deletions
10
dist/epub.js
vendored
10
dist/epub.js
vendored
|
@ -3964,7 +3964,7 @@ EPUBJS.View.prototype.expand = function(force) {
|
|||
var height = this.lockedHeight;
|
||||
|
||||
var textWidth, textHeight;
|
||||
|
||||
// console.log("expanding a")
|
||||
if(!this.iframe || this._expanding) return;
|
||||
|
||||
this._expanding = true;
|
||||
|
@ -4016,7 +4016,8 @@ EPUBJS.View.prototype.contentWidth = function(min) {
|
|||
// Save previous width
|
||||
prev = this.iframe.style.width;
|
||||
// Set the iframe size to min, width will only ever be greater
|
||||
this.iframe.style.width = 0 + "px";
|
||||
// Will preserve the aspect ratio
|
||||
this.iframe.style.width = (min || 0) + "px";
|
||||
// Get the scroll overflow width
|
||||
width = this.document.body.scrollWidth;
|
||||
// Reset iframe size back
|
||||
|
@ -4229,7 +4230,7 @@ EPUBJS.View.prototype.listeners = function() {
|
|||
EPUBJS.View.prototype.resizeListenters = function() {
|
||||
// Test size again
|
||||
clearTimeout(this.expanding);
|
||||
this.expanding = setTimeout(this.expand.bind(this), 350);
|
||||
// this.expanding = setTimeout(this.expand.bind(this), 350);
|
||||
};
|
||||
|
||||
//https://github.com/tylergaw/media-query-events/blob/master/js/mq-events.js
|
||||
|
@ -4237,7 +4238,8 @@ EPUBJS.View.prototype.mediaQueryListeners = function() {
|
|||
var sheets = this.document.styleSheets;
|
||||
var mediaChangeHandler = function(m){
|
||||
if(m.matches && !this._expanding) {
|
||||
this.expand();
|
||||
setTimeout(this.expand.bind(this), 1);
|
||||
// this.expand();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
|
4
dist/epub.min.js
vendored
4
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -97,8 +97,8 @@
|
|||
height: "100%"
|
||||
});
|
||||
|
||||
// var displayed = rendition.display("chapter_001.xhtml");
|
||||
var displayed = rendition.display();
|
||||
var displayed = rendition.display("chapter_001.xhtml");
|
||||
// var displayed = rendition.display();
|
||||
|
||||
displayed.then(function(renderer){
|
||||
// -- do stuff
|
||||
|
|
10
src/view.js
10
src/view.js
|
@ -132,7 +132,7 @@ EPUBJS.View.prototype.expand = function(force) {
|
|||
var height = this.lockedHeight;
|
||||
|
||||
var textWidth, textHeight;
|
||||
|
||||
// console.log("expanding a")
|
||||
if(!this.iframe || this._expanding) return;
|
||||
|
||||
this._expanding = true;
|
||||
|
@ -184,7 +184,8 @@ EPUBJS.View.prototype.contentWidth = function(min) {
|
|||
// Save previous width
|
||||
prev = this.iframe.style.width;
|
||||
// Set the iframe size to min, width will only ever be greater
|
||||
this.iframe.style.width = 0 + "px";
|
||||
// Will preserve the aspect ratio
|
||||
this.iframe.style.width = (min || 0) + "px";
|
||||
// Get the scroll overflow width
|
||||
width = this.document.body.scrollWidth;
|
||||
// Reset iframe size back
|
||||
|
@ -397,7 +398,7 @@ EPUBJS.View.prototype.listeners = function() {
|
|||
EPUBJS.View.prototype.resizeListenters = function() {
|
||||
// Test size again
|
||||
clearTimeout(this.expanding);
|
||||
this.expanding = setTimeout(this.expand.bind(this), 350);
|
||||
// this.expanding = setTimeout(this.expand.bind(this), 350);
|
||||
};
|
||||
|
||||
//https://github.com/tylergaw/media-query-events/blob/master/js/mq-events.js
|
||||
|
@ -405,7 +406,8 @@ EPUBJS.View.prototype.mediaQueryListeners = function() {
|
|||
var sheets = this.document.styleSheets;
|
||||
var mediaChangeHandler = function(m){
|
||||
if(m.matches && !this._expanding) {
|
||||
this.expand();
|
||||
setTimeout(this.expand.bind(this), 1);
|
||||
// this.expand();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue