Animate gallery block

2fe12ed0cf5b3fd58da409bc3a9c601eaa055acb

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +17 -2Ignore whitespace
public/scripts/extensions/gallery/index.js+17 -2
@@ -4,6 +4,8 @@ import {
44 characters,
55 getRequestHeaders,
66 event_types,
7+ animation_duration,
8+ animation_easing,
79} from '../../../script.js';
810import { groups, selected_group } from '../../group-chats.js';
911import { loadFileToDocument, delay, getBase64Async, getSanitizedFilename } from '../../utils.js';
@@ -32,7 +34,15 @@ let galleryMaxRows = 3;
3234$('#movingDivs').on('click', '.dragClose', function () {
3335 const relatedId = $(this).data('related-id');
3436 if (!relatedId) return;
3537 const relatedElement = $(`#movingDivs > .draggable[id="${relatedId}"]`).remove();
38+ relatedElement.transition({
39+ opacity: 0,
40+ duration: animation_duration,
41+ easing: animation_easing,
42+ complete: () => {
43+ relatedElement.remove();
44+ },
45+ });
3646});
3747
3848const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved';
@@ -373,7 +383,7 @@ async function makeMovable(url) {
373383 const id = 'gallery';
374384 const template = $('#generic_draggable_template').html();
375385 const newElement = $(template);
376386 newElement.css({ 'background-color',: 'var(--SmartThemeBlurTintColor)', 'opacity': 0 });
377387 newElement.attr('forChar', id);
378388 newElement.attr('id', id);
379389 newElement.find('.drag-grabber').attr('id', `${id}header`);
@@ -505,6 +515,11 @@ async function makeMovable(url) {
505515 loadMovingUIState();
506516 $(`.draggable[forChar="${id}"]`).css('display', 'block');
507517 dragElement(newElement);
518+ newElement.transition({
519+ opacity: 1,
520+ duration: animation_duration,
521+ easing: animation_easing,
522+ });
508523
509524 $(`.draggable[forChar="${id}"] img`).on('dragstart', (e) => {
510525 console.log('saw drag on avatar!');