From 9581ce16f645992d3e104cb8180aee175b242c9d Mon Sep 17 00:00:00 2001 From: cSuwwi Date: Thu, 18 Jul 2019 21:04:45 +0200 Subject: [PATCH] resize on rotate --- src/Images/Gallery.coffee | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index fd1623688..01ca014c4 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -306,19 +306,37 @@ Gallery = $.rmClass Gallery.nodes.buttons, 'gal-playing' Gallery.slideshow = false - rotateLeft: -> + rotateLeft: $.debounce 100, -> {current, frame} = Gallery.nodes {style, dataRotate} = current dataRotate = 0 if (!dataRotate || dataRotate <= -360) style.transform = 'rotate(' + (dataRotate - 90) + 'deg)' current.dataRotate = dataRotate - 90 + if (current.dataRotate == 90 || current.dataRotate == 270) + dim = g.posts[current.dataset.post]?.file.dimensions + [width, height] = dim.split 'x' + if (parseInt(width) > parseInt(height)) + style.width = Math.min(doc.clientHeight - 25 / (width / height)) + 'px' + else + style.width = '' + else + style.width = '' - rotateRight: -> + rotateRight: $.debounce 100, -> {current, frame} = Gallery.nodes {style, dataRotate} = current dataRotate = 0 if (!dataRotate || dataRotate >= 360) style.transform = 'rotate(' + (dataRotate + 90) + 'deg)' current.dataRotate = dataRotate + 90 + if (current.dataRotate == 90 || current.dataRotate == 270) + dim = g.posts[current.dataset.post]?.file.dimensions + [width, height] = dim.split 'x' + if (parseInt(width) > parseInt(height)) + style.width = Math.min(doc.clientHeight - 25 / (width / height)) + 'px' + else + style.width = '' + else + style.width = '' close: -> $.off Gallery.nodes.current, 'error', Gallery.error