mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 16:16:08 +03:00
Use Math.round instead of Math.floor and Math.ceil for overlay placement.
This commit is contained in:
parent
eba50af8fd
commit
2c73b0fb44
@ -29,6 +29,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Fix for Chrome (v45) issue that key is sometimes undefined outside of the for-in loop (#730)
|
* Fix for Chrome (v45) issue that key is sometimes undefined outside of the for-in loop (#730)
|
||||||
* World.removeAll now cancels any in-flight image loads; same for Viewer.open and Viewer.close (#734)
|
* World.removeAll now cancels any in-flight image loads; same for Viewer.open and Viewer.close (#734)
|
||||||
* Optimized adding large numbers of items to the world with collectionMode (#735)
|
* Optimized adding large numbers of items to the world with collectionMode (#735)
|
||||||
|
* Fix overlays position (use rounding instead of flooring and ceiling)
|
||||||
|
|
||||||
2.0.0:
|
2.0.0:
|
||||||
|
|
||||||
|
@ -250,8 +250,8 @@
|
|||||||
|
|
||||||
this.adjust( position, size );
|
this.adjust( position, size );
|
||||||
|
|
||||||
position = position.apply( Math.floor );
|
position = position.apply( Math.round );
|
||||||
size = size.apply( Math.ceil );
|
size = size.apply( Math.round );
|
||||||
|
|
||||||
// rotate the position of the overlay
|
// rotate the position of the overlay
|
||||||
// TODO only rotate overlays if in canvas mode
|
// TODO only rotate overlays if in canvas mode
|
||||||
|
@ -241,20 +241,20 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var expPosition = viewport.imageToViewerElementCoordinates(
|
var expPosition = viewport.imageToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 13, 120 ) ).apply( Math.floor );
|
new OpenSeadragon.Point( 13, 120 ) ).apply( Math.round );
|
||||||
var actPosition = $( "#overlay" ).position();
|
var actPosition = $( "#overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||||
|
|
||||||
var zoom = viewport.viewportToImageZoom( viewport.getZoom( true ) );
|
var zoom = viewport.viewportToImageZoom( viewport.getZoom( true ) );
|
||||||
var expectedWidth = Math.ceil( 124 * zoom );
|
var expectedWidth = Math.round( 124 * zoom );
|
||||||
var expectedHeight = Math.ceil( 132 * zoom );
|
var expectedHeight = Math.round( 132 * zoom );
|
||||||
equal( $( "#overlay" ).width(), expectedWidth, "Width mismatch " + contextMessage );
|
equal( $( "#overlay" ).width(), expectedWidth, "Width mismatch " + contextMessage );
|
||||||
equal( $( "#overlay" ).height( ), expectedHeight, "Height mismatch " + contextMessage );
|
equal( $( "#overlay" ).height( ), expectedHeight, "Height mismatch " + contextMessage );
|
||||||
|
|
||||||
|
|
||||||
expPosition = viewport.imageToViewerElementCoordinates(
|
expPosition = viewport.imageToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 400, 500 ) ).apply( Math.floor );
|
new OpenSeadragon.Point( 400, 500 ) ).apply( Math.round );
|
||||||
actPosition = $( "#fixed-overlay" ).position();
|
actPosition = $( "#fixed-overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||||
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
||||||
@ -305,7 +305,7 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.2, 0.1 ) ).apply( Math.floor );
|
new OpenSeadragon.Point( 0.2, 0.1 ) ).apply( Math.round );
|
||||||
var actPosition = $( "#overlay" ).position();
|
var actPosition = $( "#overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||||
@ -317,7 +317,7 @@
|
|||||||
|
|
||||||
|
|
||||||
expPosition = viewport.viewportToViewerElementCoordinates(
|
expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.5, 0.6 ) ).apply( Math.floor );
|
new OpenSeadragon.Point( 0.5, 0.6 ) ).apply( Math.round );
|
||||||
actPosition = $( "#fixed-overlay" ).position();
|
actPosition = $( "#fixed-overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||||
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
||||||
@ -373,7 +373,7 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.2, 0.1 ) ).apply( Math.floor );
|
new OpenSeadragon.Point( 0.2, 0.1 ) ).apply( Math.round );
|
||||||
var actPosition = $( "#overlay" ).position();
|
var actPosition = $( "#overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||||
@ -384,7 +384,7 @@
|
|||||||
|
|
||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||||
.apply( Math.floor )
|
.apply( Math.round )
|
||||||
.plus( expectedOffset );
|
.plus( expectedOffset );
|
||||||
var actPosition = $( "#fixed-overlay" ).position();
|
var actPosition = $( "#fixed-overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||||
@ -447,7 +447,7 @@
|
|||||||
|
|
||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||||
.apply( Math.floor )
|
.apply( Math.round )
|
||||||
.plus( expectedOffset );
|
.plus( expectedOffset );
|
||||||
var actPosition = $( "#fixed-overlay" ).position();
|
var actPosition = $( "#fixed-overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||||
@ -501,7 +501,7 @@
|
|||||||
|
|
||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||||
.apply( Math.floor )
|
.apply( Math.round )
|
||||||
.plus( expectedOffset );
|
.plus( expectedOffset );
|
||||||
var actPosition = $( "#fixed-overlay" ).position();
|
var actPosition = $( "#fixed-overlay" ).position();
|
||||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||||
|
Loading…
Reference in New Issue
Block a user