From 81e375d1ccf7ab0658d8b379882fe560ed347c29 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 17 Jan 2018 03:09:22 +0300 Subject: [PATCH] minor fixes to the image crop experiemnt... Signed-off-by: Alex A. Naanou --- ui (gen4)/Makefile | 5 +++-- ui (gen4)/experiments/image-crop-edit.html | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ui (gen4)/Makefile b/ui (gen4)/Makefile index 2b82364e..bdf708f0 100755 --- a/ui (gen4)/Makefile +++ b/ui (gen4)/Makefile @@ -513,13 +513,14 @@ $(DIST_DIR)/$(APP_NAME)-%.msi: $(BUILD_DIR)/$(APP_NAME)-% $(BUILD_DIR)/$(APP_NAM #---------------------------------------------------------------------- -# Debian package... +# deb/rpm package... # XXX #---------------------------------------------------------------------- -# Mobile (cordova/PhoneGap) XXX +# Mobile (cordova/PhoneGap)... +# XXX diff --git a/ui (gen4)/experiments/image-crop-edit.html b/ui (gen4)/experiments/image-crop-edit.html index a4ae066c..a9e3a05f 100755 --- a/ui (gen4)/experiments/image-crop-edit.html +++ b/ui (gen4)/experiments/image-crop-edit.html @@ -101,7 +101,11 @@ $(function(){ function setRatio(ratio){ var crop = $('.crop') + + crop .resizable("option", "aspectRatio", ratio) + // XXX this feels like a hack but it works... + .data('uiResizable')._aspectRatio = ratio if(ratio === false){ return @@ -122,8 +126,19 @@ function setRatio(ratio){ function flip(){ var crop = $('.crop') var r = crop.resizable("option", "aspectRatio") - r > 0 - && setRatio(1/r) + + if(r > 0){ + setRatio(1/r) + + // no aspect ratio defined, just switch... + } else { + var w = crop.width() + var h = crop.height() + + crop + .height(w) + .width(h) + } }