Browse Source

1v1 image load improve

master
filesite 2 months ago
parent
commit
9777e434b6
  1. 17
      www/js/beauty.js

17
www/js/beauty.js

@ -89,12 +89,25 @@ if ($('#image_site').get(0)) {
var customToolbar_show1to1 = { var customToolbar_show1to1 = {
tpl: $('#btn_show1to1_tmp').html(), tpl: $('#btn_show1to1_tmp').html(),
click: function() { click: function() {
var btn = this, fancybox = this.instance; var fancybox = this.instance;
var slide = fancybox.getSlide(); var slide = fancybox.getSlide();
if (slide.src == slide.downloadSrc) {
slide.panzoom.toggleZoom();
return false;
}
fancybox.showLoading(slide); fancybox.showLoading(slide);
//如果没有自动显示loading图标,主动加上
if ($(slide.el).find('.fancybox-spinner').length == 0) {
var spinner = '<div class="f-spinner fancybox-spinner"><svg viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle><circle cx="25" cy="25" r="20"></circle></svg></div>';
$(spinner).insertBefore(slide.contentEl);
}
$(slide.imageEl).one('load', function() { $(slide.imageEl).one('load', function() {
console.log('image loaded'); console.log('image loaded');
fancybox.hideLoading(slide); fancybox.hideLoading(slide);
$(slide.el).find('.fancybox-spinner').remove();
slide.panzoom.toggleZoom(); slide.panzoom.toggleZoom();
}); });
@ -171,7 +184,7 @@ if ($('#image_site').get(0)) {
if (!naturalWidth || naturalWidth <= min_width || naturalHeight <= min_height || if (!naturalWidth || naturalWidth <= min_width || naturalHeight <= min_height ||
(typeof(disableSmallImage) != 'undefined' && disableSmallImage) (typeof(disableSmallImage) != 'undefined' && disableSmallImage)
) { ) {
console.warn('ignored', imgEl); //console.warn('ignored', imgEl);
return false; return false;
} }

Loading…
Cancel
Save