1
0
Fork 0
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:
fchasen 2015-06-23 21:01:35 -04:00
parent 27fec5a305
commit 4a7e08c49a
4 changed files with 18 additions and 14 deletions

12
dist/epub.js vendored
View file

@ -3964,9 +3964,9 @@ 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;
// Expand Horizontally
@ -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

File diff suppressed because one or more lines are too long

View file

@ -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

View file

@ -132,9 +132,9 @@ 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;
// Expand Horizontally
@ -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);