diff --git a/app/javascript/controllers/seats_controller.js b/app/javascript/controllers/seats_controller.js
index 2a37920c..517b72f8 100644
--- a/app/javascript/controllers/seats_controller.js
+++ b/app/javascript/controllers/seats_controller.js
@@ -1,12 +1,28 @@
import { Controller } from "stimulus"
+import svgPanZoom from "svg-pan-zoom"
export default class extends Controller {
static targets = [ "map", "seat", "section", "selection" ]
connect() {
+ this.map = svgPanZoom(this.mapTarget, {
+ viewportSelector: "#map-viewport",
+ center: true,
+ fit: true,
+ zoomEnabled: false,
+ zoomScaleSensitivity: 0.75,
+ minZoom: 1.0,
+ maxZoom: 8,
+ })
this.selectSeats()
}
+ disconnect() {
+ if (!this.mapTarget.hasAttribute("data-turbolinks-permanent")) {
+ this.map.destroy()
+ }
+ }
+
discardMap() {
this.mapTarget.removeAttribute("data-turbolinks-permanent")
}
@@ -46,4 +62,12 @@ export default class extends Controller {
section.removeAttribute("aria-hidden")
})
}
+
+ zoomIn() {
+ this.map.zoomIn()
+ }
+
+ zoomOut() {
+ this.map.zoomOut()
+ }
}
diff --git a/app/views/seats/_frame.html.erb b/app/views/seats/_frame.html.erb
index dc745340..bac5db2d 100644
--- a/app/views/seats/_frame.html.erb
+++ b/app/views/seats/_frame.html.erb
@@ -91,36 +91,39 @@
- <% sections.each do |section| %>
-