mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 23:21:42 +03:00
Improve performance of Tile#drawHTML.
By specifying the tile size in absolute pixel values instead of percentages, we can save the call to $.getElementSize.
This commit is contained in:
parent
c1f0b384c8
commit
a18f0e0efb
33
src/tile.js
33
src/tile.js
@ -110,9 +110,6 @@ $.Tile.prototype = {
|
|||||||
* @param {Element} container
|
* @param {Element} container
|
||||||
*/
|
*/
|
||||||
drawHTML: function( container ) {
|
drawHTML: function( container ) {
|
||||||
|
|
||||||
var containerSize = $.getElementSize( container );
|
|
||||||
|
|
||||||
if ( !this.loaded || !this.image ) {
|
if ( !this.loaded || !this.image ) {
|
||||||
$.console.warn(
|
$.console.warn(
|
||||||
"Attempting to draw tile %s when it's not yet loaded.",
|
"Attempting to draw tile %s when it's not yet loaded.",
|
||||||
@ -121,26 +118,6 @@ $.Tile.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EXISTING IMPLEMENTATION
|
|
||||||
if ( !this.element ) {
|
|
||||||
this.element = $.makeNeutralElement("img");
|
|
||||||
this.element.src = this.url;
|
|
||||||
|
|
||||||
this.style = this.element.style;
|
|
||||||
this.style.position = "absolute";
|
|
||||||
this.style.msInterpolationMode = "nearest-neighbor";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( this.element.parentNode != container ) {
|
|
||||||
container.appendChild( this.element );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.style.top = position.y + "px";
|
|
||||||
this.style.left = position.x + "px";
|
|
||||||
this.style.height = size.y + "px";
|
|
||||||
this.style.width = size.x + "px";
|
|
||||||
*/
|
|
||||||
|
|
||||||
//EXPERIMENTAL - trying to figure out how to scale the container
|
//EXPERIMENTAL - trying to figure out how to scale the container
|
||||||
// content during animation of the container size.
|
// content during animation of the container size.
|
||||||
|
|
||||||
@ -156,14 +133,12 @@ $.Tile.prototype = {
|
|||||||
container.appendChild( this.element );
|
container.appendChild( this.element );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.style.top = 100 * ( this.position.y / containerSize.y ) + "%";
|
this.style.top = this.position.y + "px";
|
||||||
this.style.left = 100 * ( this.position.x / containerSize.x ) + "%";
|
this.style.left = this.position.x + "px";
|
||||||
this.style.height = 100 * ( this.size.y / containerSize.y ) + "%";
|
this.style.height = this.size.y + "px";
|
||||||
this.style.width = 100 * ( this.size.x / containerSize.x ) + "%";
|
this.style.width = this.size.x + "px";
|
||||||
|
|
||||||
$.setElementOpacity( this.element, this.opacity );
|
$.setElementOpacity( this.element, this.opacity );
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user