mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #44 from houqp/master
set default offset to the top of page in fit to content mode
This commit is contained in:
@@ -233,26 +233,24 @@ function UniReader:setzoom(page)
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT then
|
||||
if (x1 - x0) < pwidth then
|
||||
self.globalzoom = width / (x1 - x0)
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom + (height - (self.globalzoom * (y1 - y0))) / 2
|
||||
if height / (y1 - y0) < self.globalzoom then
|
||||
self.globalzoom = height / (y1 - y0)
|
||||
self.offset_x = -1 * x0 * self.globalzoom + (width - (self.globalzoom * (x1 - x0))) / 2
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
end
|
||||
end
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH then
|
||||
if (x1 - x0) < pwidth then
|
||||
self.globalzoom = width / (x1 - x0)
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom + (height - (self.globalzoom * (y1 - y0))) / 2
|
||||
end
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then
|
||||
if (y1 - y0) < pheight then
|
||||
self.globalzoom = height / (y1 - y0)
|
||||
self.offset_x = -1 * x0 * self.globalzoom + (width - (self.globalzoom * (x1 - x0))) / 2
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
end
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH
|
||||
or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN then
|
||||
local margin = self.pan_margin
|
||||
|
||||
Reference in New Issue
Block a user