@jsenv/dom 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_dom.js +259 -314
- package/package.json +2 -4
- package/index.js +0 -124
- package/src/attr/add_attribute_effect.js +0 -93
- package/src/attr/attributes.js +0 -32
- package/src/color/color_constrast.js +0 -69
- package/src/color/color_parsing.js +0 -319
- package/src/color/color_scheme.js +0 -28
- package/src/color/pick_light_or_dark.js +0 -34
- package/src/color/resolve_css_color.js +0 -60
- package/src/demos/3_columns_resize_demo.html +0 -84
- package/src/demos/3_rows_resize_demo.html +0 -89
- package/src/demos/aside_and_main_demo.html +0 -93
- package/src/demos/coordinates_demo.html +0 -450
- package/src/demos/document_autoscroll_demo.html +0 -517
- package/src/demos/drag_gesture_constraints_demo.html +0 -701
- package/src/demos/drag_gesture_demo.html +0 -1047
- package/src/demos/drag_gesture_element_to_impact_demo.html +0 -445
- package/src/demos/drag_reference_element_demo.html +0 -480
- package/src/demos/flex_details_set_demo.html +0 -302
- package/src/demos/flex_details_set_demo_2.html +0 -315
- package/src/demos/visible_rect_demo.html +0 -525
- package/src/element_signature.js +0 -100
- package/src/interaction/drag/constraint_feedback_line.js +0 -92
- package/src/interaction/drag/drag_constraint.js +0 -659
- package/src/interaction/drag/drag_debug_markers.js +0 -635
- package/src/interaction/drag/drag_element_positioner.js +0 -382
- package/src/interaction/drag/drag_gesture.js +0 -566
- package/src/interaction/drag/drag_resize_demo.html +0 -571
- package/src/interaction/drag/drag_to_move.js +0 -301
- package/src/interaction/drag/drag_to_resize_gesture.js +0 -68
- package/src/interaction/drag/drop_target_detection.js +0 -148
- package/src/interaction/drag/sticky_frontiers.js +0 -160
- package/src/interaction/event_marker.js +0 -14
- package/src/interaction/focus/active_element.js +0 -33
- package/src/interaction/focus/arrow_navigation.js +0 -599
- package/src/interaction/focus/element_is_focusable.js +0 -57
- package/src/interaction/focus/element_visibility.js +0 -111
- package/src/interaction/focus/find_focusable.js +0 -21
- package/src/interaction/focus/focus_group.js +0 -91
- package/src/interaction/focus/focus_group_registry.js +0 -12
- package/src/interaction/focus/focus_nav.js +0 -12
- package/src/interaction/focus/focus_nav_event_marker.js +0 -14
- package/src/interaction/focus/focus_trap.js +0 -105
- package/src/interaction/focus/tab_navigation.js +0 -128
- package/src/interaction/focus/tests/focus_group_skip_tab_test.html +0 -206
- package/src/interaction/focus/tests/tree_focus_test.html +0 -304
- package/src/interaction/focus/tests/tree_focus_test.jsx +0 -261
- package/src/interaction/focus/tests/tree_focus_test_preact.html +0 -13
- package/src/interaction/isolate_interactions.js +0 -161
- package/src/interaction/keyboard.js +0 -26
- package/src/interaction/scroll/capture_scroll.js +0 -47
- package/src/interaction/scroll/is_scrollable.js +0 -159
- package/src/interaction/scroll/scroll_container.js +0 -110
- package/src/interaction/scroll/scroll_trap.js +0 -44
- package/src/interaction/scroll/scrollbar_size.js +0 -20
- package/src/interaction/scroll/wheel_through.js +0 -138
- package/src/iterable_weak_set.js +0 -66
- package/src/position/dom_coords.js +0 -340
- package/src/position/offset_parent.js +0 -15
- package/src/position/position_fixed.js +0 -15
- package/src/position/position_sticky.js +0 -213
- package/src/position/sticky_rect.js +0 -79
- package/src/position/visible_rect.js +0 -486
- package/src/pub_sub.js +0 -31
- package/src/size/can_take_size.js +0 -11
- package/src/size/details_content_full_height.js +0 -63
- package/src/size/flex_details_set.js +0 -974
- package/src/size/get_available_height.js +0 -22
- package/src/size/get_available_width.js +0 -22
- package/src/size/get_border_sizes.js +0 -14
- package/src/size/get_height.js +0 -4
- package/src/size/get_inner_height.js +0 -15
- package/src/size/get_inner_width.js +0 -15
- package/src/size/get_margin_sizes.js +0 -10
- package/src/size/get_max_height.js +0 -57
- package/src/size/get_max_width.js +0 -47
- package/src/size/get_min_height.js +0 -14
- package/src/size/get_min_width.js +0 -14
- package/src/size/get_padding_sizes.js +0 -10
- package/src/size/get_width.js +0 -4
- package/src/size/hooks/use_available_height.js +0 -27
- package/src/size/hooks/use_available_width.js +0 -27
- package/src/size/hooks/use_max_height.js +0 -10
- package/src/size/hooks/use_max_width.js +0 -10
- package/src/size/hooks/use_resize_status.js +0 -62
- package/src/size/resize.js +0 -695
- package/src/size/resolve_css_size.js +0 -32
- package/src/style/dom_styles.js +0 -97
- package/src/style/style_composition.js +0 -121
- package/src/style/style_controller.js +0 -345
- package/src/style/style_default.js +0 -153
- package/src/style/style_default_demo.html +0 -128
- package/src/style/style_parsing.js +0 -375
- package/src/transition/demos/animation_resumption_test.xhtml +0 -500
- package/src/transition/demos/height_toggle_test.xhtml +0 -515
- package/src/transition/dom_transition.js +0 -254
- package/src/transition/easing.js +0 -48
- package/src/transition/group_transition.js +0 -261
- package/src/transition/transform_style_parser.js +0 -32
- package/src/transition/transition_playback.js +0 -366
- package/src/transition/transition_timeline.js +0 -79
- package/src/traversal.js +0 -247
- package/src/ui_transition/demos/content_states_transition_demo.html +0 -628
- package/src/ui_transition/demos/smooth_height_transition_demo.html +0 -149
- package/src/ui_transition/demos/transition_testing.html +0 -354
- package/src/ui_transition/ui_transition.js +0 -1470
- package/src/utils.js +0 -69
- package/src/value_effect.js +0 -35
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Animation Resumption Test</title>
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
margin: 0;
|
|
8
|
-
font-family: system-ui;
|
|
9
|
-
padding: 20px;
|
|
10
|
-
background: #f0f0f0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.controls {
|
|
14
|
-
background: white;
|
|
15
|
-
padding: 20px;
|
|
16
|
-
border-radius: 8px;
|
|
17
|
-
margin-bottom: 20px;
|
|
18
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.control-group {
|
|
22
|
-
margin-bottom: 16px;
|
|
23
|
-
display: flex;
|
|
24
|
-
gap: 12px;
|
|
25
|
-
align-items: center;
|
|
26
|
-
flex-wrap: wrap;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.control-group label {
|
|
30
|
-
font-weight: bold;
|
|
31
|
-
min-width: 120px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
button {
|
|
35
|
-
padding: 8px 16px;
|
|
36
|
-
border: 1px solid #ccc;
|
|
37
|
-
border-radius: 4px;
|
|
38
|
-
background: #f8f9fa;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
transition: background 0.2s;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
button:hover {
|
|
44
|
-
background: #e9ecef;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
button.active {
|
|
48
|
-
background: #0066cc;
|
|
49
|
-
color: white;
|
|
50
|
-
border-color: #0066cc;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
input[type="range"] {
|
|
54
|
-
width: 200px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
input[type="number"] {
|
|
58
|
-
width: 80px;
|
|
59
|
-
padding: 4px 8px;
|
|
60
|
-
border: 1px solid #ccc;
|
|
61
|
-
border-radius: 4px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.test-element {
|
|
65
|
-
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
|
|
66
|
-
border: 2px solid #333;
|
|
67
|
-
border-radius: 8px;
|
|
68
|
-
color: white;
|
|
69
|
-
font-weight: bold;
|
|
70
|
-
text-align: center;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: center;
|
|
74
|
-
margin: 20px 0;
|
|
75
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
76
|
-
transition: box-shadow 0.2s;
|
|
77
|
-
position: relative;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.test-element[data-height-animated] {
|
|
81
|
-
box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.test-element[data-width-animated] {
|
|
85
|
-
box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.test-element[data-transition-opacity] {
|
|
89
|
-
box-shadow: 0 6px 20px rgba(255, 255, 0, 0.4);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.test-element[data-animated] {
|
|
93
|
-
box-shadow: 0 8px 24px rgba(0, 102, 204, 0.5);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.status {
|
|
97
|
-
background: white;
|
|
98
|
-
padding: 16px;
|
|
99
|
-
border-radius: 8px;
|
|
100
|
-
margin-bottom: 20px;
|
|
101
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.status-item {
|
|
105
|
-
margin: 8px 0;
|
|
106
|
-
padding: 8px;
|
|
107
|
-
border-radius: 4px;
|
|
108
|
-
background: #f8f9fa;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.status-item.playing {
|
|
112
|
-
background: #d4edda;
|
|
113
|
-
border-left: 4px solid #28a745;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.status-item.paused {
|
|
117
|
-
background: #fff3cd;
|
|
118
|
-
border-left: 4px solid #ffc107;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.status-item.ended {
|
|
122
|
-
background: #f8d7da;
|
|
123
|
-
border-left: 4px solid #dc3545;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.debug-log {
|
|
127
|
-
background: #1e1e1e;
|
|
128
|
-
color: #00ff00;
|
|
129
|
-
padding: 16px;
|
|
130
|
-
border-radius: 8px;
|
|
131
|
-
font-family: monospace;
|
|
132
|
-
font-size: 12px;
|
|
133
|
-
height: 200px;
|
|
134
|
-
overflow-y: auto;
|
|
135
|
-
margin-top: 20px;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.progress-bar {
|
|
139
|
-
width: 100%;
|
|
140
|
-
height: 20px;
|
|
141
|
-
background: #e9ecef;
|
|
142
|
-
border-radius: 10px;
|
|
143
|
-
overflow: hidden;
|
|
144
|
-
margin: 8px 0;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.progress-fill {
|
|
148
|
-
height: 100%;
|
|
149
|
-
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
|
|
150
|
-
transition: width 0.1s linear;
|
|
151
|
-
border-radius: 10px;
|
|
152
|
-
}
|
|
153
|
-
</style>
|
|
154
|
-
</head>
|
|
155
|
-
<body>
|
|
156
|
-
<h1>Animation Target Update Test</h1>
|
|
157
|
-
<p>
|
|
158
|
-
Test dynamic animation target updates using the new updateTarget API in
|
|
159
|
-
animation_playback.js
|
|
160
|
-
</p>
|
|
161
|
-
|
|
162
|
-
<div class="controls">
|
|
163
|
-
<h3>Animation Controls</h3>
|
|
164
|
-
|
|
165
|
-
<div class="control-group">
|
|
166
|
-
<label>Duration:</label>
|
|
167
|
-
<input type="number" id="duration" value="3000" min="100" step="100" />
|
|
168
|
-
<span>ms</span>
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
<div class="control-group">
|
|
172
|
-
<label>Animation Type:</label>
|
|
173
|
-
<button id="height-btn" class="active">Height</button>
|
|
174
|
-
<button id="width-btn">Width</button>
|
|
175
|
-
<button id="opacity-btn">Opacity</button>
|
|
176
|
-
<button id="combined-btn">Combined</button>
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<div class="control-group">
|
|
180
|
-
<label>Height Target:</label>
|
|
181
|
-
<input type="range" id="height-slider" min="50" max="400" value="200" />
|
|
182
|
-
<input type="number" id="height-value" value="200" min="50" max="400" />
|
|
183
|
-
<span>px</span>
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
<div class="control-group">
|
|
187
|
-
<label>Width Target:</label>
|
|
188
|
-
<input type="range" id="width-slider" min="100" max="600" value="300" />
|
|
189
|
-
<input type="number" id="width-value" value="300" min="100" max="600" />
|
|
190
|
-
<span>px</span>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
<div class="control-group">
|
|
194
|
-
<label>Opacity Target:</label>
|
|
195
|
-
<input
|
|
196
|
-
type="range"
|
|
197
|
-
id="opacity-slider"
|
|
198
|
-
min="0"
|
|
199
|
-
max="1"
|
|
200
|
-
step="0.1"
|
|
201
|
-
value="0.5"
|
|
202
|
-
/>
|
|
203
|
-
<input
|
|
204
|
-
type="number"
|
|
205
|
-
id="opacity-value"
|
|
206
|
-
value="0.5"
|
|
207
|
-
min="0"
|
|
208
|
-
max="1"
|
|
209
|
-
step="0.1"
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
|
|
213
|
-
<div class="control-group">
|
|
214
|
-
<label>Actions:</label>
|
|
215
|
-
<button id="start-btn">Start Animation</button>
|
|
216
|
-
<button id="interrupt-btn" disabled>Update Target</button>
|
|
217
|
-
<button id="pause-btn" disabled>Pause</button>
|
|
218
|
-
<button id="resume-btn" disabled>Resume</button>
|
|
219
|
-
<button id="reset-btn">Reset Element</button>
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<div class="status">
|
|
224
|
-
<h3>Animation Status</h3>
|
|
225
|
-
<div id="status-content">
|
|
226
|
-
<div class="status-item">Ready to start animation</div>
|
|
227
|
-
</div>
|
|
228
|
-
<div class="progress-bar">
|
|
229
|
-
<div class="progress-fill" id="progress-fill" style="width: 0%"></div>
|
|
230
|
-
</div>
|
|
231
|
-
<div id="progress-text">Progress: 0%</div>
|
|
232
|
-
</div>
|
|
233
|
-
|
|
234
|
-
<div
|
|
235
|
-
id="test-element"
|
|
236
|
-
class="test-element"
|
|
237
|
-
style="width: 200px; height: 150px; opacity: 1"
|
|
238
|
-
>
|
|
239
|
-
Test Element
|
|
240
|
-
</div>
|
|
241
|
-
|
|
242
|
-
<div class="debug-log" id="debug-log"></div>
|
|
243
|
-
|
|
244
|
-
<script type="module">
|
|
245
|
-
import {
|
|
246
|
-
createHeightAnimation,
|
|
247
|
-
createWidthAnimation,
|
|
248
|
-
createOpacityAnimation,
|
|
249
|
-
createPlaybackGroup,
|
|
250
|
-
} from "@jsenv/dom";
|
|
251
|
-
|
|
252
|
-
const testElement = document.getElementById("test-element");
|
|
253
|
-
const debugLog = document.getElementById("debug-log");
|
|
254
|
-
const statusContent = document.getElementById("status-content");
|
|
255
|
-
const progressFill = document.getElementById("progress-fill");
|
|
256
|
-
const progressText = document.getElementById("progress-text");
|
|
257
|
-
|
|
258
|
-
// Controls
|
|
259
|
-
const durationInput = document.getElementById("duration");
|
|
260
|
-
const heightSlider = document.getElementById("height-slider");
|
|
261
|
-
const heightValue = document.getElementById("height-value");
|
|
262
|
-
const widthSlider = document.getElementById("width-slider");
|
|
263
|
-
const widthValue = document.getElementById("width-value");
|
|
264
|
-
const opacitySlider = document.getElementById("opacity-slider");
|
|
265
|
-
const opacityValue = document.getElementById("opacity-value");
|
|
266
|
-
|
|
267
|
-
// Buttons
|
|
268
|
-
const heightBtn = document.getElementById("height-btn");
|
|
269
|
-
const widthBtn = document.getElementById("width-btn");
|
|
270
|
-
const opacityBtn = document.getElementById("opacity-btn");
|
|
271
|
-
const combinedBtn = document.getElementById("combined-btn");
|
|
272
|
-
const startBtn = document.getElementById("start-btn");
|
|
273
|
-
const interruptBtn = document.getElementById("interrupt-btn");
|
|
274
|
-
const pauseBtn = document.getElementById("pause-btn");
|
|
275
|
-
const resumeBtn = document.getElementById("resume-btn");
|
|
276
|
-
const resetBtn = document.getElementById("reset-btn");
|
|
277
|
-
|
|
278
|
-
let currentAnimation = null;
|
|
279
|
-
let animationType = "height";
|
|
280
|
-
|
|
281
|
-
// Sync slider and number inputs
|
|
282
|
-
heightSlider.oninput = () => {
|
|
283
|
-
heightValue.value = heightSlider.value;
|
|
284
|
-
};
|
|
285
|
-
heightValue.oninput = () => {
|
|
286
|
-
heightSlider.value = heightValue.value;
|
|
287
|
-
};
|
|
288
|
-
widthSlider.oninput = () => {
|
|
289
|
-
widthValue.value = widthSlider.value;
|
|
290
|
-
};
|
|
291
|
-
widthValue.oninput = () => {
|
|
292
|
-
widthSlider.value = widthValue.value;
|
|
293
|
-
};
|
|
294
|
-
opacitySlider.oninput = () => {
|
|
295
|
-
opacityValue.value = opacitySlider.value;
|
|
296
|
-
};
|
|
297
|
-
opacityValue.oninput = () => {
|
|
298
|
-
opacitySlider.value = opacityValue.value;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// Animation type selection
|
|
302
|
-
[heightBtn, widthBtn, opacityBtn, combinedBtn].forEach((btn) => {
|
|
303
|
-
btn.onclick = () => {
|
|
304
|
-
document
|
|
305
|
-
.querySelectorAll(".control-group button")
|
|
306
|
-
.forEach((b) => b.classList.remove("active"));
|
|
307
|
-
btn.classList.add("active");
|
|
308
|
-
animationType = btn.id.replace("-btn", "");
|
|
309
|
-
log(`Animation type changed to: ${animationType}`);
|
|
310
|
-
};
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
function log(message) {
|
|
314
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
315
|
-
debugLog.innerHTML += `[${timestamp}] ${message}<br>`;
|
|
316
|
-
debugLog.scrollTop = debugLog.scrollHeight;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function updateStatus(message, type = "") {
|
|
320
|
-
statusContent.innerHTML = `<div class="status-item ${type}">${message}</div>`;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function updateProgress(progress) {
|
|
324
|
-
const percentage = Math.round(progress * 100);
|
|
325
|
-
progressFill.style.width = `${percentage}%`;
|
|
326
|
-
progressText.textContent = `Progress: ${percentage}%`;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function updateButtons(playing) {
|
|
330
|
-
startBtn.disabled = playing;
|
|
331
|
-
interruptBtn.disabled = !playing;
|
|
332
|
-
pauseBtn.disabled =
|
|
333
|
-
!playing ||
|
|
334
|
-
(currentAnimation && currentAnimation.playState === "finished");
|
|
335
|
-
resumeBtn.disabled =
|
|
336
|
-
playing ||
|
|
337
|
-
!currentAnimation ||
|
|
338
|
-
currentAnimation.playState !== "paused";
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function resetElement() {
|
|
342
|
-
if (currentAnimation) {
|
|
343
|
-
currentAnimation.cancel();
|
|
344
|
-
currentAnimation = null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
testElement.style.width = "200px";
|
|
348
|
-
testElement.style.height = "150px";
|
|
349
|
-
testElement.style.opacity = "1";
|
|
350
|
-
testElement.style.transform = "";
|
|
351
|
-
|
|
352
|
-
updateStatus("Element reset to initial state");
|
|
353
|
-
updateProgress(0);
|
|
354
|
-
updateButtons(false);
|
|
355
|
-
log("Element reset to initial state");
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function createAnimation() {
|
|
359
|
-
const duration = parseInt(durationInput.value);
|
|
360
|
-
|
|
361
|
-
log(`Creating ${animationType} animation (duration: ${duration}ms)`);
|
|
362
|
-
|
|
363
|
-
const commonOptions = {
|
|
364
|
-
duration,
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
switch (animationType) {
|
|
368
|
-
case "height":
|
|
369
|
-
return createHeightAnimation(
|
|
370
|
-
testElement,
|
|
371
|
-
parseInt(heightValue.value),
|
|
372
|
-
commonOptions,
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
case "width":
|
|
376
|
-
return createWidthAnimation(
|
|
377
|
-
testElement,
|
|
378
|
-
parseInt(widthValue.value),
|
|
379
|
-
commonOptions,
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
case "opacity":
|
|
383
|
-
return createOpacityAnimation(
|
|
384
|
-
testElement,
|
|
385
|
-
parseFloat(opacityValue.value),
|
|
386
|
-
commonOptions,
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
case "combined": {
|
|
390
|
-
const animations = [
|
|
391
|
-
createHeightAnimation(testElement, parseInt(heightValue.value), {
|
|
392
|
-
...commonOptions,
|
|
393
|
-
}),
|
|
394
|
-
createWidthAnimation(testElement, parseInt(widthValue.value), {
|
|
395
|
-
...commonOptions,
|
|
396
|
-
}),
|
|
397
|
-
createOpacityAnimation(
|
|
398
|
-
testElement,
|
|
399
|
-
parseFloat(opacityValue.value),
|
|
400
|
-
{
|
|
401
|
-
...commonOptions,
|
|
402
|
-
},
|
|
403
|
-
),
|
|
404
|
-
];
|
|
405
|
-
const animGroup = createPlaybackGroup(animations);
|
|
406
|
-
return animGroup;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
default:
|
|
410
|
-
log(`Unknown animation type: ${animationType}`);
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
startBtn.onclick = () => {
|
|
416
|
-
if (currentAnimation) {
|
|
417
|
-
currentAnimation.cancel();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
currentAnimation = createAnimation();
|
|
421
|
-
|
|
422
|
-
// Set up progress callback using channels
|
|
423
|
-
currentAnimation.channels.progress.add(({ progress }) => {
|
|
424
|
-
updateProgress(progress);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
currentAnimation.play();
|
|
428
|
-
|
|
429
|
-
updateStatus("Animation started", "playing");
|
|
430
|
-
updateButtons(true);
|
|
431
|
-
log(`Started ${animationType} animation`);
|
|
432
|
-
|
|
433
|
-
// Handle animation end
|
|
434
|
-
currentAnimation.channels.finish.add(() => {
|
|
435
|
-
updateStatus("Animation completed", "ended");
|
|
436
|
-
updateButtons(false);
|
|
437
|
-
log("Animation completed");
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
interruptBtn.onclick = () => {
|
|
442
|
-
if (!currentAnimation || currentAnimation.playState === "finished") {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
log(`Interrupting animation and updating target`);
|
|
447
|
-
|
|
448
|
-
// Update target using the new updateTarget method
|
|
449
|
-
switch (animationType) {
|
|
450
|
-
case "height":
|
|
451
|
-
currentAnimation.updateTarget(parseInt(heightValue.value));
|
|
452
|
-
log(`Updated height target to ${heightValue.value}px`);
|
|
453
|
-
break;
|
|
454
|
-
case "width":
|
|
455
|
-
currentAnimation.updateTarget(parseInt(widthValue.value));
|
|
456
|
-
log(`Updated width target to ${widthValue.value}px`);
|
|
457
|
-
break;
|
|
458
|
-
case "opacity":
|
|
459
|
-
currentAnimation.updateTarget(parseFloat(opacityValue.value));
|
|
460
|
-
log(`Updated opacity target to ${opacityValue.value}`);
|
|
461
|
-
break;
|
|
462
|
-
case "combined":
|
|
463
|
-
// For combined animations, we need to update each individual animation
|
|
464
|
-
log(`Combined animations don't support updateTarget yet`);
|
|
465
|
-
break;
|
|
466
|
-
default:
|
|
467
|
-
log(`Unknown animation type: ${animationType}`);
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
updateStatus("Animation target updated", "playing");
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
pauseBtn.onclick = () => {
|
|
475
|
-
if (currentAnimation && currentAnimation.pause) {
|
|
476
|
-
currentAnimation.pause();
|
|
477
|
-
updateStatus("Animation paused", "paused");
|
|
478
|
-
updateButtons(false);
|
|
479
|
-
log("Animation paused");
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
resumeBtn.onclick = () => {
|
|
484
|
-
if (currentAnimation && currentAnimation.play) {
|
|
485
|
-
currentAnimation.play();
|
|
486
|
-
updateStatus("Animation resumed", "playing");
|
|
487
|
-
updateButtons(true);
|
|
488
|
-
log("Animation resumed");
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
resetBtn.onclick = resetElement;
|
|
493
|
-
|
|
494
|
-
// Initialize
|
|
495
|
-
log("Animation target update test initialized with new updateTarget API");
|
|
496
|
-
updateStatus("Ready to start animation");
|
|
497
|
-
updateButtons(false);
|
|
498
|
-
</script>
|
|
499
|
-
</body>
|
|
500
|
-
</html>
|