From 1bbb54c716b34584feb68a5280a89b089fb2b155 Mon Sep 17 00:00:00 2001 From: Roel van Hintum Date: Fri, 17 May 2024 10:27:27 +0200 Subject: [PATCH] #17 image editor refactored --- CHANGELOG.md | 4 + .../imagehotspotsfield/dist/css/Input.css | 57 ++--- .../imagehotspotsfield/dist/js/Editor.js | 216 ++++++++++++++---- 3 files changed, 209 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2d6f5b..5d1ec18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 3.0.0-beta.2 - 2024-05-17 +- #17 image editor refactored to support zoom and panning (using scroll and drag) +- points can now be dragged around + ## 3.0.0-beta.1 - 2024-03-22 Hotspots are not yet prefilled with data from nested entries as used in the new Matrix fields. diff --git a/src/assetbundles/imagehotspotsfield/dist/css/Input.css b/src/assetbundles/imagehotspotsfield/dist/css/Input.css index 11b2263..7e4a50e 100644 --- a/src/assetbundles/imagehotspotsfield/dist/css/Input.css +++ b/src/assetbundles/imagehotspotsfield/dist/css/Input.css @@ -8,44 +8,43 @@ } .image-hotspot-editor { - padding-bottom: 58px; + background-color: var(--gray-900); + color: var(--white); + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + --focus-ring: 0 0 0 1px hsl(var(--light-focus-hsl)), 0 0 0 3px hsla(var(--light-focus-hsl),0.7); + opacity: 0; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + border-radius: 0; } .image-hotspot-editor .body { - position: relative; - height: 100%; - display: flex; - align-items: center; - justify-content: center; + padding: 0; } -.image-hotspot-editor .image-container { - position: relative; - display: inline-block; - user-select: none; - z-index: 0; +.image-hotspot-editor .footer { + background-color: transparent; + border-top: 1px solid #000; + bottom: 0; + left: 0; + position: absolute; width: 100%; - height: 100%; -} -.image-hotspot-editor .image-container.align-height { - width: auto; -} -.image-hotspot-editor .image-container.align-width { - height: auto; } -.image-hotspot-editor img { - max-height: 100%; - max-width: 100%; +.image-hotspot-container { + position: absolute; display: block; -} - -.image-hotspot-editor .align-height img { + z-index: 0; + width: 100%; height: 100%; + opacity: 0; } -.image-hotspot-editor .align-width img { - width: 100%; +.image-hotspot-editor img { + display: block; } .image-hotspot-editor .point, @@ -68,3 +67,9 @@ width: 100%; margin: 0; } + +.image-hotspot-buttons { + position: absolute; + right: 20px; + bottom: 20px; +} \ No newline at end of file diff --git a/src/assetbundles/imagehotspotsfield/dist/js/Editor.js b/src/assetbundles/imagehotspotsfield/dist/js/Editor.js index 52bfc19..e269d84 100644 --- a/src/assetbundles/imagehotspotsfield/dist/js/Editor.js +++ b/src/assetbundles/imagehotspotsfield/dist/js/Editor.js @@ -5,13 +5,26 @@ if (typeof Born05 === 'undefined') var Born05 = {}; Born05.ImageHotspotEditor = Garnish.Modal.extend({ + $body: null, + $footer: null, + $buttons: null, + $img: null, - $cancelBtn: null, + $saveBtn: null, $imgContainer: null, asset: null, pos: null, listData: null, + imageBounds: null, + + isDraggingImage: false, + isDraggingPoint: false, + previousMouseX: 0, + previousMouseY: 0, + + prevOffsetX: 0, + prevOffsetY: 0, init: function(asset, pos, listData, settings) { this.setSettings(settings, Born05.ImageHotspotEditor.defaults); @@ -21,46 +34,88 @@ Born05.ImageHotspotEditor = Garnish.Modal.extend({ this.updateData(listData); // Build the modal - var $container = $('').appendTo(Garnish.$bod); - var $body = $('
').appendTo($container); - var $footer = $('