Browse code

Add zoom slider and animate zoom

Benjamin Roth authored on10/10/2024 16:07:09
Showing2 changed files
... ...
@@ -9,6 +9,8 @@
9 9
 {% block main %}
10 10
     <div class="tl_panel">
11 11
         <div id="vr-daily-schedule-zoom" class="tl_submit_panel">
12
+            <label for="daily-zoom-slider">Zoom</label>
13
+            <input type="range" id="daily-zoom-slider" min="1.5" max="9" step="1.5" value="3">
12 14
             <button id="daily-zoom-in" class="tl_submit">+</button>
13 15
             <button id="daily-zoom-out" class="tl_submit">-</button>
14 16
             <button id="daily-zoom-reset" class="tl_submit" data-default="3">Reset</button>
... ...
@@ -35,8 +37,17 @@
35 37
                     {
36 38
                         root.style.setProperty('--slot-height',defaultZoom);
37 39
                     }
40
+                    zoomPanel.querySelector('#daily-zoom-slider').value = parseFloat(rootStyles.getPropertyValue('--slot-height'));
38 41
                 });
39 42
             });
43
+
44
+            zoomPanel.querySelector('#daily-zoom-slider').addEventListener('input',(event) => {
45
+                let currentVal = rootStyles.getPropertyValue('--slot-height');
46
+                let split = currentVal.match(/^([-.\d]+(?:\.\d+)?)(.*)$/);
47
+                [value,unit] = [parseFloat(split[1]),split[2] ? split[2] : ''];
48
+
49
+                root.style.setProperty('--slot-height',event.target.value + unit);
50
+            });
40 51
         </script>
41 52
     </div>
42 53
     <div class="vr-daily-schedule">
... ...
@@ -9,8 +9,13 @@ $time-color: #666;
9 9
 $text-color: #333;
10 10
 $header-bg-color: #f2f2f2;
11 11
 $slot-height: 3rem;
12
+$slot-animation-duration: .25s;
12 13
 $cell-amount: 48;
13 14
 
15
+@mixin animate-slot {
16
+  transition: height $slot-animation-duration ease-in-out, line-height $slot-animation-duration ease-in-out, grid-template-rows $slot-animation-duration ease-in-out;
17
+}
18
+
14 19
 :root {
15 20
   --slot-height: #{$slot-height};
16 21
 }
... ...
@@ -43,6 +48,7 @@ $cell-amount: 48;
43 48
     position: relative;
44 49
     padding-inline-end: 8px;
45 50
     text-align: right;
51
+    @include animate-slot;
46 52
 
47 53
     &:first-child {
48 54
       .daily-timeline-label {
... ...
@@ -77,6 +83,7 @@ $cell-amount: 48;
77 83
 
78 84
     .line {
79 85
       height: var(--slot-height);
86
+      @include animate-slot;
80 87
 
81 88
       &:after {
82 89
         content: "";
... ...
@@ -109,9 +116,11 @@ $cell-amount: 48;
109 116
       width: 100%;
110 117
       display: grid;
111 118
       grid-template-rows: repeat($cell-amount, calc(var(--slot-height) / (#{$cell-amount} / 24)));
119
+      @include animate-slot;
112 120
 
113 121
       .event-cell {
114 122
         line-height: calc(var(--slot-height) / 4);
123
+        @include animate-slot;
115 124
         z-index: 2;
116 125
         box-sizing: border-box;
117 126
         border-radius: 5px;