Skip to content

Commit 5a42ec6

Browse files
committed
webui/js: opt dialog animation
1 parent 2c3f2db commit 5a42ec6

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

webui/index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,56 @@ function initSwitch(path, id) {
330330
});
331331
}
332332

333+
// Overwrite default dialog animation
334+
document.querySelectorAll('md-dialog').forEach(dialog => {
335+
const defaulfOpenAnim = dialog.getOpenAnimation;
336+
const defaultCloseAnim = dialog.getCloseAnimation;
337+
338+
dialog.getOpenAnimation = () => {
339+
const defaultAnim = defaulfOpenAnim.call(dialog);
340+
const customAnim = {};
341+
Object.keys(defaultAnim).forEach(key => customAnim[key] = defaultAnim[key]);
342+
343+
customAnim.dialog = [
344+
[
345+
[{ opacity: 0, transform: 'translateY(50px)' }, { opacity: 1, transform: 'translateY(0)' }],
346+
{ duration: 300, easing: 'ease' }
347+
]
348+
];
349+
customAnim.scrim = [
350+
[
351+
[{'opacity': 0}, {'opacity': 0.32}],
352+
{duration: 300, easing: 'linear'},
353+
],
354+
];
355+
customAnim.container = [];
356+
357+
return customAnim;
358+
};
359+
360+
dialog.getCloseAnimation = () => {
361+
const defaultAnim = defaultCloseAnim.call(dialog);
362+
const customAnim = {};
363+
Object.keys(defaultAnim).forEach(key => customAnim[key] = defaultAnim[key]);
364+
365+
customAnim.dialog = [
366+
[
367+
[{ opacity: 1, transform: 'translateY(0)' }, { opacity: 0, transform: 'translateY(-50px)' }],
368+
{ duration: 300, easing: 'ease' }
369+
]
370+
];
371+
customAnim.scrim = [
372+
[
373+
[{'opacity': 0.32}, {'opacity': 0}],
374+
{duration: 300, easing: 'linear'},
375+
],
376+
];
377+
customAnim.container = [];
378+
379+
return customAnim;
380+
};
381+
});
382+
333383
document.addEventListener('DOMContentLoaded', async () => {
334384
[config, configMetadata] = await Promise.all([file.loadConfig(), file.loadConfigMetadata()]);
335385
const advanced = document.getElementById('advanced');

0 commit comments

Comments
 (0)