Skip to content

Commit b1cfc13

Browse files
committed
Merge pull request #33 from israelidanny/master
Fix auto-height issues for pages
2 parents 46dc123 + 19a5d62 commit b1cfc13

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • public/javascripts/DV/models

public/javascripts/DV/models/page.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ DV.model.Pages.prototype = {
9393
// Update the height for a page, when its real image has loaded.
9494
updateHeight: function(image, pageIndex) {
9595
var h = this.getPageHeight(pageIndex);
96-
var height = image.height * (this.zoomLevel > this.BASE_WIDTH ? 0.7 : 1.0);
96+
// we want to preserve the original image's ratio, but not it's literal height
97+
var ratio = image.height / image.width;
98+
// the height will be adjusted according to the real width of the page taking into account the original ratio
99+
var height = this.width * ratio * (this.zoomLevel > this.BASE_WIDTH ? 0.7 : 1.0);
100+
97101
if (image.width < this.baseWidth) {
98102
// Not supposed to happen, but too-small images sometimes do.
99103
height *= (this.baseWidth / image.width);

0 commit comments

Comments
 (0)