Animate gallery block
| @@ -4,6 +4,8 @@ import { | ||
| 4 | 4 | characters, |
| 5 | 5 | getRequestHeaders, |
| 6 | 6 | event_types, |
| 7 | + animation_duration, | |
| 8 | + animation_easing, | |
| 7 | 9 | } from '../../../script.js'; |
| 8 | 10 | import { groups, selected_group } from '../../group-chats.js'; |
| 9 | 11 | import { loadFileToDocument, delay, getBase64Async, getSanitizedFilename } from '../../utils.js'; |
| @@ -32,7 +34,15 @@ let galleryMaxRows = 3; | ||
| 32 | 34 | $('#movingDivs').on('click', '.dragClose', function () { |
| 33 | 35 | const relatedId = $(this).data('related-id'); |
| 34 | 36 | if (!relatedId) return; |
| 35 | 37 | 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 | + }); | |
| 36 | 46 | }); |
| 37 | 47 | |
| 38 | 48 | const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved'; |
| @@ -373,7 +383,7 @@ async function makeMovable(url) { | ||
| 373 | 383 | const id = 'gallery'; |
| 374 | 384 | const template = $('#generic_draggable_template').html(); |
| 375 | 385 | const newElement = $(template); |
| 376 | 386 | newElement.css({ 'background-color',: 'var(--SmartThemeBlurTintColor)', 'opacity': 0 }); |
| 377 | 387 | newElement.attr('forChar', id); |
| 378 | 388 | newElement.attr('id', id); |
| 379 | 389 | newElement.find('.drag-grabber').attr('id', `${id}header`); |
| @@ -505,6 +515,11 @@ async function makeMovable(url) { | ||
| 505 | 515 | loadMovingUIState(); |
| 506 | 516 | $(`.draggable[forChar="${id}"]`).css('display', 'block'); |
| 507 | 517 | dragElement(newElement); |
| 518 | + newElement.transition({ | |
| 519 | + opacity: 1, | |
| 520 | + duration: animation_duration, | |
| 521 | + easing: animation_easing, | |
| 522 | + }); | |
| 508 | 523 | |
| 509 | 524 | $(`.draggable[forChar="${id}"] img`).on('dragstart', (e) => { |
| 510 | 525 | console.log('saw drag on avatar!'); |