|
2 | 2 | * #%L |
3 | 3 | * digilib-webapp |
4 | 4 | * %% |
5 | | - * Copyright (C) 2011 - 2017 MPIWG Berlin, Bibliotheca Hertziana |
| 5 | + * Copyright (C) 2011 - 2023 MPIWG Berlin, Bibliotheca Hertziana |
6 | 6 | * %% |
7 | 7 | * This program is free software: you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU Lesser General Public License as |
@@ -94,8 +94,8 @@ function($) { |
94 | 94 | // save digilib state in cookie for embedded mode |
95 | 95 | 'saveStateInCookie' : true, |
96 | 96 | // default size of preview image for drag-scroll (preferrably same as Bird's Eye View image) |
97 | | - 'previewImgWidth' : 200, |
98 | | - 'previewImgHeight' : 200, |
| 97 | + 'previewImgWidth' : 400, |
| 98 | + 'previewImgHeight' : 400, |
99 | 99 | // maximum width or height of preview background image for drag-scroll |
100 | 100 | 'maxBgSize' : 10000, |
101 | 101 | // parameters used by background image |
@@ -202,14 +202,7 @@ function($) { |
202 | 202 | unpackParams(data); |
203 | 203 | // list of current insets (dynamic for buttons etc.) |
204 | 204 | data.currentInsets = {'static' : elemSettings.scalerInsets}; |
205 | | - // check if browser knows *background-size |
206 | | - for (var bs in {'':1, '-moz-':1, '-webkit-':1, '-o-':1}) { |
207 | | - if ($elem.css(bs+'background-size')) { |
208 | | - data.hasBgSize = true; |
209 | | - data.bgSizeName = bs+'background-size'; |
210 | | - break; |
211 | | - } |
212 | | - } |
| 205 | + // background as preview using background-size |
213 | 206 | data.hasPreviewBg = false; |
214 | 207 | // check if browser supports AJAX-like URL-replace without reload |
215 | 208 | data.hasAsyncReload = (typeof history.replaceState === 'function'); |
@@ -1492,6 +1485,12 @@ function($) { |
1492 | 1485 | */ |
1493 | 1486 | var setPreviewBg = function(data, newZoomArea) { |
1494 | 1487 | var $scaler = data.$scaler; |
| 1488 | + if (data.settings.rot % 90 != 0) { |
| 1489 | + // remove background for oblique angle rotations |
| 1490 | + $scaler.css({'background-image': 'none'}); |
| 1491 | + data.hasPreviewBg = false; |
| 1492 | + return; |
| 1493 | + } |
1495 | 1494 | var imgTrafo = data.imgTrafo; |
1496 | 1495 | var scalerPos = geom.position($scaler); |
1497 | 1496 | var bgRect = null; |
@@ -1524,26 +1523,23 @@ function($) { |
1524 | 1523 | // position background |
1525 | 1524 | scalerCss['background-position'] = Math.round(bgRect.x) + 'px '+ Math.round(bgRect.y) + 'px'; |
1526 | 1525 | } |
1527 | | - if (data.hasBgSize) { |
1528 | | - // scale background using CSS3-background-size |
1529 | | - if (bgRect != null && (bgRect.height < data.settings.maxBgSize && bgRect.width < data.settings.maxBgSize)) { |
1530 | | - scalerCss[data.bgSizeName] = Math.round(bgRect.width) + 'px ' + Math.round(bgRect.height) + 'px'; |
1531 | | - } else { |
1532 | | - scalerCss[data.bgSizeName] = 'auto'; |
1533 | | - } |
1534 | | - // additional full-size background using CSS3 |
1535 | | - fullRect = imgTrafo.transform(FULL_AREA); |
1536 | | - if (fullRect.height < data.settings.maxBgSize && fullRect.width < data.settings.maxBgSize) { |
1537 | | - // correct offset because background is relative |
1538 | | - fullRect.addPosition(scalerPos.neg()); |
1539 | | - var url = getPreviewImgUrl(data); |
1540 | | - // add second background url, size and position |
1541 | | - scalerCss['background-image'] += ', url(' + url + ')'; |
1542 | | - scalerCss[data.bgSizeName] += ', ' + Math.round(fullRect.width) + 'px ' + Math.round(fullRect.height) + 'px'; |
1543 | | - scalerCss['background-position'] += ', ' + Math.round(fullRect.x) + 'px '+ Math.round(fullRect.y) + 'px'; |
1544 | | - } |
| 1526 | + // scale background using CSS3-background-size |
| 1527 | + if (bgRect != null && (bgRect.height < data.settings.maxBgSize && bgRect.width < data.settings.maxBgSize)) { |
| 1528 | + scalerCss['background-size'] = Math.round(bgRect.width) + 'px ' + Math.round(bgRect.height) + 'px'; |
| 1529 | + } else { |
| 1530 | + scalerCss['background-size'] = 'auto'; |
| 1531 | + } |
| 1532 | + // additional full-size background using CSS3 |
| 1533 | + fullRect = imgTrafo.transform(FULL_AREA); |
| 1534 | + if (fullRect.height < data.settings.maxBgSize && fullRect.width < data.settings.maxBgSize) { |
| 1535 | + // correct offset because background is relative |
| 1536 | + fullRect.addPosition(scalerPos.neg()); |
| 1537 | + var url = getPreviewImgUrl(data); |
| 1538 | + // add second background url, size and position |
| 1539 | + scalerCss['background-image'] += ', url(' + url + ')'; |
| 1540 | + scalerCss['background-size'] += ', ' + Math.round(fullRect.width) + 'px ' + Math.round(fullRect.height) + 'px'; |
| 1541 | + scalerCss['background-position'] += ', ' + Math.round(fullRect.x) + 'px '+ Math.round(fullRect.y) + 'px'; |
1545 | 1542 | } |
1546 | | - // console.debug('* setPreviewBg', scalerCss[data.bgSizeName], 'pos', scalerCss['background-position']); |
1547 | 1543 | $scaler.css(scalerCss); |
1548 | 1544 | data.hasPreviewBg = true; |
1549 | 1545 | }; |
|
0 commit comments