Skip to content

Commit 90af0cd

Browse files
committed
v1.3.0-b2
- Added animation when thumbnail rotated
1 parent 8f1d651 commit 90af0cd

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

imcger/imgupload/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Using ImageMagick php librarie for resize image attachments and creating thumbnails.",
55
"homepage": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
6-
"version": "1.3.0-b1",
7-
"time": "2023-10-07",
6+
"version": "1.3.0-b2",
7+
"time": "2023-10-08",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{

imcger/imgupload/controller/save_rotated_img_controller.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,25 @@ private function rotate_image($path, $deg)
192192
}
193193

194194
/**
195-
* Generate json return
195+
* Generate json string
196196
*
197197
* @param int $status Status 0=id's, 3=redirect, 4=file not found, 5=error
198198
* @param string $title Messagebox title
199199
* @param string $message Messagebox message
200-
* @param int $old_attach_id Rotation angle
201-
* @param int $new_attach_id Path to the image file
200+
* @param int $old_attach_id Previous attachment id
201+
* @param int $new_attach_id New attachment id
202202
*
203203
* @return string $json
204204
*/
205205
private function json_response($status, $title = '', $message = '', $old_attach_id = 0, $new_attach_id = 0)
206206
{
207-
$json = new JsonResponse(array(
207+
$json = new JsonResponse([
208208
'status' => (int) $status,
209209
'title' => $title,
210210
'message' => $message,
211211
'oldAttachId' => (int) $old_attach_id,
212212
'newAttachId' => (int) $new_attach_id,
213-
));
213+
]);
214214

215215
return $json;
216216
}

imcger/imgupload/styles/all/template/event/overall_footer_body_after.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,27 @@
132132
imgOrientationIndex: [],
133133
imgOrientationValue: [],
134134

135-
rotate: function(attach_id, deg) {
136-
let image = document.getElementById('img-' + attach_id);
135+
rotate: function(attach_id, deg, clockwise) {
136+
let image = document.getElementById('img-' + attach_id),
137+
deg_start, deg_ziel;
138+
139+
if (clockwise) {
140+
deg_ziel = deg == 0 ? 360 : deg;
141+
deg_start = deg_ziel - 90;
142+
} else {
143+
deg_ziel = (deg - 360) == (-360) ? 0 : (deg - 360);
144+
deg_start = deg_ziel + 90;
145+
}
146+
147+
image.animate(
148+
[
149+
{ transform: 'rotate(' + deg_start + 'deg)' },
150+
{ transform: 'rotate(' + deg_ziel + 'deg)' },
151+
],
152+
{
153+
duration: 150,
154+
},
155+
);
137156

138157
image.style.webkitTransform = 'rotate(' + deg + 'deg)';
139158
image.style.mozTransform = 'rotate(' + deg + 'deg)';
@@ -157,7 +176,7 @@
157176
this.imgOrientationValue[index] = 0;
158177
}
159178

160-
this.rotate(attach_id, this.imgOrientationValue[index]);
179+
this.rotate(attach_id, this.imgOrientationValue[index], true);
161180
},
162181

163182
rotateLeft: function(attach_id) {
@@ -176,7 +195,7 @@
176195
this.imgOrientationValue[index] += 360;
177196
}
178197

179-
this.rotate(attach_id, this.imgOrientationValue[index]);
198+
this.rotate(attach_id, this.imgOrientationValue[index], false);
180199
},
181200
}
182201

0 commit comments

Comments
 (0)