mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Merge pull request #741 from avandecreme/master
Use Math.round instead of Math.floor and Math.ceil for overlay placement
This commit is contained in:
commit
fd501a0aee
@ -30,6 +30,7 @@ OPENSEADRAGON CHANGELOG
|
||||
* 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)
|
||||
* 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:
|
||||
|
||||
|
@ -250,8 +250,8 @@
|
||||
|
||||
this.adjust( position, size );
|
||||
|
||||
position = position.apply( Math.floor );
|
||||
size = size.apply( Math.ceil );
|
||||
position = position.apply( Math.round );
|
||||
size = size.apply( Math.round );
|
||||
|
||||
// rotate the position of the overlay
|
||||
// TODO only rotate overlays if in canvas mode
|
||||
|
@ -241,20 +241,20 @@
|
||||
var viewport = viewer.viewport;
|
||||
|
||||
var expPosition = viewport.imageToViewerElementCoordinates(
|
||||
new OpenSeadragon.Point( 13, 120 ) ).apply( Math.floor );
|
||||
new OpenSeadragon.Point( 13, 120 ) ).apply( Math.round );
|
||||
var actPosition = $( "#overlay" ).position();
|
||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||
|
||||
var zoom = viewport.viewportToImageZoom( viewport.getZoom( true ) );
|
||||
var expectedWidth = Math.ceil( 124 * zoom );
|
||||
var expectedHeight = Math.ceil( 132 * zoom );
|
||||
var expectedWidth = Math.round( 124 * zoom );
|
||||
var expectedHeight = Math.round( 132 * zoom );
|
||||
equal( $( "#overlay" ).width(), expectedWidth, "Width mismatch " + contextMessage );
|
||||
equal( $( "#overlay" ).height( ), expectedHeight, "Height mismatch " + contextMessage );
|
||||
|
||||
|
||||
expPosition = viewport.imageToViewerElementCoordinates(
|
||||
new OpenSeadragon.Point( 400, 500 ) ).apply( Math.floor );
|
||||
new OpenSeadragon.Point( 400, 500 ) ).apply( Math.round );
|
||||
actPosition = $( "#fixed-overlay" ).position();
|
||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
||||
@ -305,7 +305,7 @@
|
||||
var viewport = viewer.viewport;
|
||||
|
||||
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();
|
||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||
@ -317,7 +317,7 @@
|
||||
|
||||
|
||||
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();
|
||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||
equal( actPosition.top, expPosition.y, "Fixed overlay Y position mismatch " + contextMessage );
|
||||
@ -373,7 +373,7 @@
|
||||
var viewport = viewer.viewport;
|
||||
|
||||
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();
|
||||
equal( actPosition.left, expPosition.x, "X position mismatch " + contextMessage );
|
||||
equal( actPosition.top, expPosition.y, "Y position mismatch " + contextMessage );
|
||||
@ -384,7 +384,7 @@
|
||||
|
||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||
.apply( Math.floor )
|
||||
.apply( Math.round )
|
||||
.plus( expectedOffset );
|
||||
var actPosition = $( "#fixed-overlay" ).position();
|
||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||
@ -447,7 +447,7 @@
|
||||
|
||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||
.apply( Math.floor )
|
||||
.apply( Math.round )
|
||||
.plus( expectedOffset );
|
||||
var actPosition = $( "#fixed-overlay" ).position();
|
||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||
@ -501,7 +501,7 @@
|
||||
|
||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||
new OpenSeadragon.Point( 0.5, 0.6 ) )
|
||||
.apply( Math.floor )
|
||||
.apply( Math.round )
|
||||
.plus( expectedOffset );
|
||||
var actPosition = $( "#fixed-overlay" ).position();
|
||||
equal( actPosition.left, expPosition.x, "Fixed overlay X position mismatch " + contextMessage );
|
||||
|
Loading…
Reference in New Issue
Block a user