From a70d082be3e9c3b961a217a712aca762f42ba653 Mon Sep 17 00:00:00 2001 From: gwills Date: Mon, 14 Oct 2013 10:59:20 +0100 Subject: [PATCH] Fix rotate on rectangular overalys Use size after rotate when positioning the overlay. Also removed check on this.scales - was there a reason these were not handled when rotating? If so we can add a option here maybe. --- src/overlay.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/overlay.js b/src/overlay.js index b828ac9e..f3df6cfb 100644 --- a/src/overlay.js +++ b/src/overlay.js @@ -211,13 +211,14 @@ // TODO replace the size rotation with CSS3 transforms // TODO add an option to overlays to not rotate with the image // Currently only rotates position and size - if( degrees !== 0 && this.scales ) { - overlayCenter = new $.Point( size.x / 2, size.y / 2 ); - + if( degrees !== 0 ) { + overlayCenter = new $.Point( size.x / 2, size.y / 2 ); + var overlayCenterAfterRotate = (degrees === 0 || degrees === 180) ? overlayCenter : new $.Point( size.y / 2, size.x / 2 ); + position = position.plus( overlayCenter ).rotate( degrees, drawerCenter - ).minus( overlayCenter ); + ).minus( overlayCenterAfterRotate ); size = size.rotate( degrees, new $.Point( 0, 0 ) ); size = new $.Point( Math.abs( size.x ), Math.abs( size.y ) );