mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
add support for placeholderFillStyle to webgl drawer. fix spring logic to avoid getting stuck updating due to floating point math. update tilesource-swap demo.
This commit is contained in:
parent
f7d86ac244
commit
5b2c6d7ed9
@ -212,7 +212,7 @@ $.Spring.prototype = {
|
|||||||
update: function() {
|
update: function() {
|
||||||
this.current.time = $.now();
|
this.current.time = $.now();
|
||||||
|
|
||||||
var startValue, targetValue;
|
let startValue, targetValue;
|
||||||
if (this._exponential) {
|
if (this._exponential) {
|
||||||
startValue = this.start._logValue;
|
startValue = this.start._logValue;
|
||||||
targetValue = this.target._logValue;
|
targetValue = this.target._logValue;
|
||||||
@ -221,9 +221,10 @@ $.Spring.prototype = {
|
|||||||
targetValue = this.target.value;
|
targetValue = this.target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentValue = (this.current.time >= this.target.time) ?
|
if(this.current.time >= this.target.time){
|
||||||
targetValue :
|
this.current.value = this.target.value;
|
||||||
startValue +
|
} else {
|
||||||
|
let currentValue = startValue +
|
||||||
( targetValue - startValue ) *
|
( targetValue - startValue ) *
|
||||||
transform(
|
transform(
|
||||||
this.springStiffness,
|
this.springStiffness,
|
||||||
@ -236,8 +237,9 @@ $.Spring.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
this.current.value = currentValue;
|
this.current.value = currentValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return currentValue !== targetValue;
|
return this.current.value !== this.target.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,6 +239,10 @@
|
|||||||
|
|
||||||
let tilesToDraw = tiledImage.getTilesToDraw();
|
let tilesToDraw = tiledImage.getTilesToDraw();
|
||||||
|
|
||||||
|
if ( tiledImage.placeholderFillStyle && tiledImage._hasOpaqueTile === false ) {
|
||||||
|
this._drawPlaceholder(tiledImage);
|
||||||
|
}
|
||||||
|
|
||||||
if(tilesToDraw.length === 0 || tiledImage.getOpacity() === 0){
|
if(tilesToDraw.length === 0 || tiledImage.getOpacity() === 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1077,6 +1081,30 @@
|
|||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_drawPlaceholder(tiledImage){
|
||||||
|
|
||||||
|
const bounds = tiledImage.getBounds(true);
|
||||||
|
const rect = this.viewportToDrawerRectangle(tiledImage.getBounds(true));
|
||||||
|
const context = this._outputContext;
|
||||||
|
|
||||||
|
let fillStyle;
|
||||||
|
if ( typeof tiledImage.placeholderFillStyle === "function" ) {
|
||||||
|
fillStyle = tiledImage.placeholderFillStyle(tiledImage, context);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fillStyle = tiledImage.placeholderFillStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.save();
|
||||||
|
context.fillStyle = fillStyle;
|
||||||
|
context.translate(rect.x, rect.y);
|
||||||
|
context.rotate(Math.PI / 180 * bounds.degrees);
|
||||||
|
context.translate(-rect.x, -rect.y);
|
||||||
|
context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
||||||
|
context.restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// private
|
// private
|
||||||
_restoreRotationChanges() {
|
_restoreRotationChanges() {
|
||||||
var context = this._outputContext;
|
var context = this._outputContext;
|
||||||
|
@ -32,17 +32,18 @@
|
|||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels: [
|
levels: [
|
||||||
{
|
{
|
||||||
url: 'http://openseadragon.github.io/example-images/duomo/duomo_files/8/0_0.jpg',
|
url: 'https://openseadragon.github.io/example-images/duomo/duomo_files/8/0_0.jpg',
|
||||||
width: 218,
|
width: 218,
|
||||||
height: 160
|
height: 160
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
degrees: 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
var duomo = {
|
var duomo = {
|
||||||
Image: {
|
Image: {
|
||||||
xmlns: 'http://schemas.microsoft.com/deepzoom/2008',
|
xmlns: 'http://schemas.microsoft.com/deepzoom/2008',
|
||||||
Url: 'http://openseadragon.github.io/example-images/duomo/duomo_files/',
|
Url: 'https://openseadragon.github.io/example-images/duomo/duomo_files/',
|
||||||
Format: 'jpg',
|
Format: 'jpg',
|
||||||
Overlap: '2',
|
Overlap: '2',
|
||||||
TileSize: '256',
|
TileSize: '256',
|
||||||
@ -59,10 +60,11 @@
|
|||||||
tileSources: duomoStandin,
|
tileSources: duomoStandin,
|
||||||
minZoomImageRatio: 0.1,
|
minZoomImageRatio: 0.1,
|
||||||
defaultZoomLevel: 0.1,
|
defaultZoomLevel: 0.1,
|
||||||
zoomPerClick: 1
|
zoomPerClick: 1,
|
||||||
|
crossOriginPolicy: 'Anonymous'
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('canvas-click', function(event) {
|
viewer.addOnceHandler('canvas-click', function(event) {
|
||||||
if (event.quick) {
|
if (event.quick) {
|
||||||
var standin = viewer.world.getItemAt(0);
|
var standin = viewer.world.getItemAt(0);
|
||||||
var standinBounds = standin.getBounds();
|
var standinBounds = standin.getBounds();
|
||||||
@ -76,13 +78,10 @@
|
|||||||
index: 0, // Add the new image below the stand-in.
|
index: 0, // Add the new image below the stand-in.
|
||||||
success: function(event) {
|
success: function(event) {
|
||||||
var fullImage = event.item;
|
var fullImage = event.item;
|
||||||
|
// The changeover will look better if we wait for the first draw after the changeover.
|
||||||
// The changeover will look better if we wait for the first tile to be drawn.
|
|
||||||
var tileDrawnHandler = function(event) {
|
var tileDrawnHandler = function(event) {
|
||||||
if (event.tiledImage === fullImage) {
|
|
||||||
viewer.removeHandler('update-viewport', tileDrawnHandler);
|
viewer.removeHandler('update-viewport', tileDrawnHandler);
|
||||||
viewer.world.removeItem(standin);
|
viewer.world.removeItem(standin);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('update-viewport', tileDrawnHandler);
|
viewer.addHandler('update-viewport', tileDrawnHandler);
|
||||||
|
Loading…
Reference in New Issue
Block a user