Add spinner while loading preview

pull/1/head
yflory 5 years ago
parent 6a10ec711a
commit d8d515a450

@ -114,7 +114,6 @@
align-items: center;
justify-content: center;
.cp-mediatag-container {
height: 100%;
width: 100%;
media-tag {
& > * {
@ -132,6 +131,10 @@
color: @cryptpad_text_col;
}
}
.cp-spinner {
border-color: @colortheme_logo-1;
border-top-color: transparent;
}
}
}
}

@ -237,21 +237,27 @@ define([
}).show().focus();
var $container = $modal.find('.cp-modal').append(h('div.cp-mediatag-container', [
h('div.cp-loading-spinner-container', h('span.cp-spinner')),
tag
]));
var el;
var checkSize = function () {
if (!el) { return; }
$container.find('.cp-mediatag-container').css('height', '');
var size = el.naturalHeight || el.videoHeight;
if (el.nodeName !== 'IMG' && el.nodeName !== 'VIDEO') {
$container.find('.cp-mediatag-container').css('height', '100%');
}
if (!size) { return; }
// Center small images and videos
if (size && size < $container.height()) {
$container.find('.cp-mediatag-container').css('height', '100%');
if (size < $container.height()) {
$container.find('.cp-mediatag-container').css('height', 'auto');
}
};
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
$container.find('.cp-loading-spinner-container').remove();
if (mutation.addedNodes.length === 1) {
el = mutation.addedNodes[0];
if (el.readyState === 0) {

Loading…
Cancel
Save