diff options
| author | eltrac <hi@eltr.ac> | 2026-11-09 14:41:10 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-11-09 14:41:10 +0800 |
| commit | f54f12619adcfac448b94b754ff3dbe07a3d4116 (patch) | |
| tree | ebd85099ca904d56a13b5eb1198efc84e7b51601 /assets | |
| parent | fef1d2499365edb10fe36bd8ae8c1d7750fe9383 (diff) | |
assets, includes, libs...: 移除 gazeimg,用原生 loading="lazy" 替代懒加载
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/css/gazeimg.css | 82 | ||||
| -rw-r--r-- | assets/js/gazeimg.js | 322 | ||||
| -rw-r--r-- | assets/js/miracles.min.js | 6 |
3 files changed, 1 insertions, 409 deletions
diff --git a/assets/css/gazeimg.css b/assets/css/gazeimg.css deleted file mode 100644 index 8198e7c..0000000 --- a/assets/css/gazeimg.css +++ /dev/null @@ -1,82 +0,0 @@ -/* ================================================== -* GazeImg v1.4.1 -* -* 采用 GPLv3 许可证供开源使用 -* 或用于商业用途的 GazeImg 商业许可证 -* 所有商业应用程序(包括您计划出售的网站,主题和应用程序) -* 都需要具有商业许可证。 -* -* Licensed GPLv3 for open source use -* or GazeImg Commercial License for commercial use -* -* http://www.ganxiaozhe.com/p/gazeimg/ -* Copyright 2020 Ganxiaozhe -* -================================================== */ -img[data-giwait-text],img[data-gionload] {filter: brightness(.2);transition: filter 1s ease-in;} -img[data-gazeimg],.gazeimg-content[data-rlong="n"] img {cursor: pointer;} -.gazeimg-content[data-rlong="y"] img {cursor: zoom-in !important;} -.gazeimg-content[data-gzoom="out"] img {cursor: zoom-out;} - -.gi-darken { - filter: brightness(1);animation:gia-darken 2s infinite linear alternate-reverse; - display: flex;align-items: center;justify-content: center; - vertical-align: top;overflow: hidden;position: relative; -} -.gi-darken.gi-failload {animation: none;} -.gi-darken a {display: block;text-decoration: none;color: #fff !important;text-align: center;word-break: break-all;} -@-webkit-keyframes gia-darken {to{filter: brightness(.75);}} -@keyframes gia-darken {to{filter: brightness(.75);}} - -.gi-zoomIn {animation: gia-zoomIn 1s cubic-bezier(0, 0, 0, 1) 1;} -@-webkit-keyframes gia-zoomIn{0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}50%{opacity:1}} -@keyframes gia-zoomIn{0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}50%{opacity:1}} - -.gi-fadeIn {animation: gia-fadeIn 0.3s cubic-bezier(0, 0, 0, 1) 1;} -@-webkit-keyframes gia-fadeIn{0%{opacity:0;}100%{opacity:1}} -@keyframes gia-fadeIn{0%{opacity:0;}100%{opacity:1}} - -.gazeimg-nobar {overflow: hidden;height: auto;} -.gazeimg-container { - position: fixed;left: 0;top: 0;height: 100%;width: 100%; - outline: none;z-index: 20020214;transition-duration: 0.35s; -} -.gazeimg-bg { - background: rgb(20,20,20);opacity: 0.9; - transition-property: opacity;transition-duration: inherit;transition-timing-function: cubic-bezier(.5, 0, .7, .7); -} -.gazeimg-bg,.gazeimg-inner { - position: absolute;top: 0;left: 0;bottom: 0;right: 0; -} -.gazeimg-stage { - direction: ltr;transform: translateZ(0); - width:100%;height:100%;padding:50px 0; -} -.gazeimg-content { - position: absolute;top:0;left:0;width:38px;height:38px;overflow: visible; - transform-origin: center; - transition: height 0.3s ease,width 0.3s ease; -} -.gazeimg-content img { - width:100%;height:100%;max-width:100%;max-height:100%;overflow: hidden; - position: absolute;top: 0;left: 0; - border:none;padding:0;margin:0; - user-select: none;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none; -} -.gazeimg-content .loader,.gilazy-loader { - display: block;width: 46px;height: 46px; - position: absolute;top:calc(50% - 23px);left:calc(50% - 23px); - border: 4px solid #f3f3f3;border-radius: 100%; - border-top: 4px solid transparent; - transition: border 0.3s ease; -} - -.gi-spin {-webkit-animation:gi-spin 0.8s infinite linear;animation:gi-spin 0.8s infinite linear;} -@-webkit-keyframes gi-spin{ - 0%{-webkit-transform:rotate(0);transform:rotate(0);} - 100%{-webkit-transform:rotate(360deg);transform:rotate(360deg);} -} -@keyframes gi-spin{ - 0%{-webkit-transform:rotate(0);transform:rotate(0);} - 100%{-webkit-transform:rotate(360deg);transform:rotate(360deg);} -} diff --git a/assets/js/gazeimg.js b/assets/js/gazeimg.js deleted file mode 100644 index 2edf649..0000000 --- a/assets/js/gazeimg.js +++ /dev/null @@ -1,322 +0,0 @@ -// ================================================== -// GazeImg v1.4.1 -// -// 采用 GPLv3 许可证供开源使用 -// 或用于商业用途的 GazeImg 商业许可证 -// 所有商业应用程序(包括您计划出售的网站,主题和应用程序) -// 都需要具有商业许可证。 -// -// Licensed GPLv3 for open source use -// or GazeImg Commercial License for commercial use -// -// http://www.ganxiaozhe.com/p/gazeimg/ -// Copyright 2020 Ganxiaozhe -// -// -// 根据 GPLv3 协议,下面是对此文件的修改说明 -// + 添加对 ReferrerPolicy 的支持以便绕过同源检测 => Line: 294 -// -- @kengwang at 2020/07/16 -// -// ================================================== -;(function($,window,document){ - 'use strict'; - - if(!$) {return '缺少JQuery!';} - let g = {t:{}}; - g.colors = [ - "linear-gradient(to right, #C3E1CA, #E6E1BD)","linear-gradient(to right, #D4D3DD, #EFEFBB)", - "linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%)","linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%)", - "linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.15) 100%)", - "linear-gradient(to top, #c1dfc4 0%, #deecdd 100%)","linear-gradient(to top, #d5d4d0 0%, #d5d4d0 1%, #eeeeec 31%, #efeeec 75%, #e9e9e7 100%);" - ]; - - function sizeHandle(opts){ - if(typeof opts!='object'){return false;} - - for (var val in opts){ - opts[val] = parseInt( String(opts[val]).replace(/px/,'') ); - } - opts.w <= 0 || isNaN(opts.w) && (opts.w=128); - opts.h <= 0 || isNaN(opts.h) && (opts.h=128); - - if( opts.w<opts.rw && opts.h<opts.rh ){return opts;} - - if(opts.w >= opts.rw && opts.w >= opts.h){ - opts.h = opts.rw / opts.w * opts.h; - opts.w = opts.rw; - } - if(opts.h > opts.rh && opts.h > opts.w){ - opts.w = opts.rh / opts.h * opts.w; - opts.h = opts.rh; - } - return opts; - } - - $.fn.giLazy = function(data){ - let t = {}; - data || (data = {}); - data.colors || (data.colors=["#000"]); - - this.each(function(){ - let timg = {}; - timg.pw = $(this).parent().width(); - timg.ph = $(this).parent().height(); - - t.gisize = 0; - t.gsrc = $(this).attr('data-gisrc').split(' '); - $(this).attr('data-gisrc',t.gsrc[0]); - if(t.gsrc[1] && t.gsrc[1].indexOf('size') > -1){ - t.gisize = t.gsrc[1].replace(/size='(.*?)'/g,'$1').split(','); - - var ti_s = sizeHandle({ - w:t.gisize[0],h:t.gisize[1], - rw:timg.pw,rh:timg.ph - }); - $(this).width(ti_s.w).height(ti_s.h); - } - - // 是否有src数据,若无则替换为div蒙版 - timg.src = $(this).attr('src') || false; - if(!timg.src){ - // 获取图片具有的css信息即其父元素的长宽 来决定替代图片的遮罩层尺寸 - timg.disp = $(this).css("display"); - - timg.msize = $(this).attr('gimask-size') || false; - if(timg.msize){ - timg.msize = timg.msize.split(','); - } else {timg.msize = [];} - typeof timg.msize[0]=='undefined' && (timg.msize[0]=false); - typeof timg.msize[1]=='undefined' && (timg.msize[1]=false); - - if(t.gisize!=0){ - timg.w = t.gisize[0]; - timg.h = t.gisize[1]; - } - timg.w = timg.msize[0] || $(this).width(); - timg.h = timg.msize[1] || $(this).height(); - - var ti_s = sizeHandle({ - w:timg.w,h:timg.h, - rw:timg.pw,rh:timg.ph - }); - timg.w = ti_s.w+'px';timg.h = ti_s.h+'px'; - - // 若图片display被设置为了inline 则将遮罩层设为inline-flex 否则继承图片display - timg.disp == "inline" ? timg.tdisp = "inline-flex" : timg.tdisp = timg.disp; - timg.tdisp = timg.tdisp.replace(/block/,'flex'); - timg.css = "width:"+timg.w+";height:"+timg.h+";background:"+data.colors[Math.floor(Math.random()*data.colors.length)]+";"; - - timg.css += "display:"+timg.tdisp; - $(this).attr('data-disp',timg.disp).css({"display":"none"}).after('<div class="gi-darken" style="'+timg.css+'"><a href="//ganxiaozhe.com/p/gazeimg/" target="_blank"><div class="gilazy-loader gi-spin"></div></a></div>'); - } else { - $(this).addClass('gi-darken'); - } - - if( $(this).attr('data-gazeimg')!=undefined ){$(this).giPrePop();} - }).attr('data-gi-init',''); - - setTimeout(()=>{$(window).scroll();},200); - - return this; - }; - - $.fn.giPrePop = function(){ - let t = {}; - this.on("click",function(){ - t.src = $(this).attr('src') || $(this).attr('data-gazeimg'); - if(!t.src){return;} - - t.stage = "<div class='gazeimg-container gi-fadeIn'><div class='gazeimg-bg'></div><div class='gazeimg-inner'><div class='gazeimg-nav'></div><div class='gazeimg-stage'><div class='gazeimg-content'><div class='loader gi-spin'></div></div></div></div><div class='gazeimg-thumbs'></div></div>"; - $('body').append(t.stage).addClass('gazeimg-nobar'); - - g.t.gcc=0; - $('.gazeimg-container').on({ - touchstart: function(e){ - g.t.gcc=1; - let elem = e.originalEvent.target || e.target; - if($(elem).is('.gazeimg-content') || $(elem).is('.gazeimg-content *')){ - return; - } - giStageClose();g.t.gcc=0; - }, - mouseup: function(e){ - if(g.t.gcc==1){return;} - let elem = e.target; - if($(elem).is('.gazeimg-content') || $(elem).is('.gazeimg-content *')){ - return; - } - giStageClose(); - } - }); - - t.i = new Image(); - t.i.src = t.src; - if(t.i.complete){giShow(t.i);} else { - t.i.onload = function(){giShow(this);} - } - }); - }; - - function giShow(img){ - g.itemp = {}; - g.itemp.rw = img.width;g.itemp.rh = img.height; - giSizeInit(img); - - $('.gazeimg-content').html('<img src="'+img.src+'">'); - $('.gazeimg-content').on({ - mousedown: function(e){ - if(e.which == 3){return;} - g.itemp.cd = true;g.itemp.clkt = 1; - $('.gazeimg-content img').css("cursor","grabbing"); - - g.t.dx = e.pageX,g.t.dy = e.pageY; - g.t.tran = $('.gazeimg-content').css('transform').replace(/[^0-9\-,]/g,'').split(','); - if(g.t.tran.length!=6) {g.t.tran = [0,0,0,0,0,0];} - }, - mouseleave:function(){ - g.itemp.cd = false; - }, - mousemove: function(e){ - if(!g.itemp.cd) {return;} - g.itemp.cd = 'moving';e.preventDefault(); - - g.t.x = parseInt(g.t.tran[4]) + e.pageX - g.t.dx; - g.t.y = parseInt(g.t.tran[5]) + e.pageY - g.t.dy; - - $('.gazeimg-content').css({'transform':'translate('+g.t.x+'px,'+g.t.y+'px)'}); - }, - mouseup: function(e){ - if(e.which == 3 || g.itemp.clkt == 2){return;} - if(g.itemp.cd!='moving'){giShowEnd();} - - g.itemp.cd = false;$('.gazeimg-content img').css("cursor","grab"); - }, - touchstart:function(e){ - g.itemp.cd = true;g.itemp.clkt++; - - g.t.dx = e.originalEvent.changedTouches[0].pageX; - g.t.dy = e.originalEvent.changedTouches[0].pageY; - g.t.tran = $('.gazeimg-content').css('transform').replace(/[^0-9\-,]/g,'').split(','); - if(g.t.tran.length!=6) {g.t.tran = [0,0,0,0,0,0];} - }, - touchmove:function(e) { - if(!g.itemp.cd) {return;} - g.itemp.cd = 'moving';e.preventDefault(); - - g.t.x = parseInt(g.t.tran[4]) + e.originalEvent.changedTouches[0].pageX - g.t.dx; - g.t.y = parseInt(g.t.tran[5]) + e.originalEvent.changedTouches[0].pageY - g.t.dy; - - $('.gazeimg-content').css({'transform':'translate('+g.t.x+'px,'+g.t.y+'px)'}); - }, - touchend:function(){ - if(g.itemp.cd!='moving' && g.itemp.clkt==1){giShowEnd();} - g.itemp.cd = false; - } - }); - function giShowEnd(){ - let t = {tgt:0}; - t.gzoom = $('.gazeimg-content').attr('data-gzoom') || ''; - - if(t.gzoom=='out') { - $('.gazeimg-content').css({'transform':'translate('+g.itemp.left+'px,'+g.itemp.top+'px) scale(1,1)'}); - $('.gazeimg-content').height(g.itemp.h).width(g.itemp.w).attr({'data-rlong':'y','data-gzoom':'in'}); - t.tgt++; - } - if( (g.itemp.rw > g.ww || g.itemp.rh > g.wh) && t.gzoom!='out' ){ - $('.gazeimg-content').css({'transform':'translate('+0+'px,'+0+'px) scale(1,1)'}); - $('.gazeimg-content').height(g.itemp.rh).width(g.itemp.rw).attr({'data-rlong':'n','data-gzoom':'out'}); - t.tgt++; - } - if(t.tgt==0){giStageClose();} - } - } - function giSizeInit(img){ - if(!g.itemp) {return false;} - - g.ww = window.innerWidth;g.wh = window.innerHeight; - g.sw = $('.gazeimg-stage').width();g.sh = $('.gazeimg-stage').height(); - - if(!img) {img = $('.gazeimg-content img')[0];} - g.itemp = giSizeProcess(img); - - $('.gazeimg-content').height(g.itemp.h).width(g.itemp.w); - - $('.gazeimg-content').css({'transform':'translate('+g.itemp.left+'px,'+g.itemp.top+'px) scale(1,1)'}); - } - function giStageClose(){ - $('.gazeimg-content').height(0).width(0); - $('.gazeimg-container').fadeOut(500,function(){ - $(this).remove(); - $('body').removeClass('gazeimg-nobar'); - }); - } - - function giSizeProcess(img){ - let t = {}; - g.sw = $('.gazeimg-stage').width();g.sh = $('.gazeimg-stage').height(); - - t = sizeHandle({ - w:g.itemp.rw,h:g.itemp.rh, - rw:g.sw,rh:g.sh - }); - t.rw = g.itemp.rw,t.rh = g.itemp.rh; - - if(t.w > g.sw) { - t.w = g.sw;t.h = t.w / t.rw * t.rh; - } - if(t.h > g.sh) { - t.h = g.sh;t.w = t.h / t.rh * t.rw; - } - - // 获取图片相对于屏幕的各数据 - t.left = parseInt((g.ww - t.w) / 2);t.top = parseInt((g.wh - t.h) / 2); - - return t; - } - - $(window).resize(function(){giSizeInit();}); - $('img[data-gisrc]:not([data-gi-init])').giLazy({'colors':g.colors}); -})(jQuery,window,document); - -$(window).scroll(function(){ - let t = {}; - t.deh = document.documentElement.clientHeight; - $('img[data-gi-init]').each(function(){ - if( $(this).next(".gi-darken").length > 0 ){ - t.ietop = $(this).next(".gi-darken")[0].getBoundingClientRect().top; - } else { - t.ietop = $(this)[0].getBoundingClientRect().top; - } - - if( t.ietop < t.deh ){ - let i = new Image(); - i.src = $(this).attr('data-gisrc'); - if (this.referrerPolicy==="no-referrer"){ - i.referrerPolicy="no-referrer"; - } - i.obj = $(this); - - if (i.complete) {icomplete(i.obj);return;}; - i.onerror = function(){ - if( i.obj.next(".gi-darken").length > 0 ){ - i.obj.next(".gi-darken").html('<a href="'+i.src+'" target="_blank">图片 '+i.src+' 加载失败;</a>').css({'background':'#000'}); - } - i.obj.removeAttr('data-gisrc').removeAttr('data-gi-init'); - - i = i.onload = i.onerror = null; - }; - i.onload = function(){ - icomplete(i.obj);i = i.onload = i.onerror = null; - }; - } - }); - - function icomplete(obj){ - obj.next(".gi-darken").remove(); - obj.attr({"src":obj.attr('data-gisrc')}).css({"display":obj.attr('data-disp')}).addClass('gi-fadeIn'); - obj.removeAttr('data-gisrc').removeAttr('data-gi-init'); - setTimeout(()=>{ - obj.css({filter:"brightness(1)"}); - },200); - } -}); diff --git a/assets/js/miracles.min.js b/assets/js/miracles.min.js index 6965f95..90672f5 100644 --- a/assets/js/miracles.min.js +++ b/assets/js/miracles.min.js @@ -175,10 +175,6 @@ $(window).scroll(function() { /** * Js Loader */ -//LazyLoad -function LazyLoad() { - $('img[data-gisrc]:not([data-gi-init])').giLazy(); -} //highlight function highlight() { $(document).ready(function() { @@ -516,4 +512,4 @@ if (loadPjax = true) { -eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e.d("%c \\f\\g h i %c j 7 8://9.a %c ","b: #6; 1: 2 0; 3: 4 0; 5: #k;","1: 2 0; 3: 4 0; 5: #l;","m: n;1-o:-0.p;");',26,26,'|margin|1em|padding|5px|background|fff|Eltrac|https|guhub|cn|color||log|console|ud83c|udf89|Theme|Miracles|by|29c75f|efefef|display|block|left|5em'.split('|'),0,{}))
\ No newline at end of file +eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e.d("%c \\f\\g h i %c j 7 8://9.a %c ","b: #6; 1: 2 0; 3: 4 0; 5: #k;","1: 2 0; 3: 4 0; 5: #l;","m: n;1-o:-0.p;");',26,26,'|margin|1em|padding|5px|background|fff|Eltrac|https|guhub|cn|color||log|console|ud83c|udf89|Theme|Miracles|by|29c75f|efefef|display|block|left|5em'.split('|'),0,{})) |
