perf(khira): eliminate UI lag and jitter with GPU-composited glass, rAF translate3d lens, and zero-overhead borders
This commit is contained in:
+18
-14
@@ -170,36 +170,38 @@ function initKubeLens() {
|
||||
|
||||
let isDragging = false;
|
||||
let startX = 0, startY = 0;
|
||||
let initialLeft = 240, initialTop = 180;
|
||||
let curX = 240, curY = 180;
|
||||
let rafId = null;
|
||||
|
||||
lens.addEventListener('pointerdown', (e) => {
|
||||
if (e.target.closest('.kube-lens-close')) return;
|
||||
isDragging = true;
|
||||
lens.setPointerCapture(e.pointerId);
|
||||
startX = e.clientX;
|
||||
startY = e.clientY;
|
||||
const rect = lens.getBoundingClientRect();
|
||||
initialLeft = rect.left;
|
||||
initialTop = rect.top;
|
||||
startX = e.clientX - curX;
|
||||
startY = e.clientY - curY;
|
||||
lens.style.transition = 'none';
|
||||
});
|
||||
|
||||
lens.addEventListener('pointermove', (e) => {
|
||||
if (!isDragging) return;
|
||||
const dx = e.clientX - startX;
|
||||
const dy = e.clientY - startY;
|
||||
const maxW = Math.max(window.innerWidth - 220, 0);
|
||||
const maxH = Math.max(window.innerHeight - 160, 0);
|
||||
const newLeft = Math.max(0, Math.min(maxW, initialLeft + dx));
|
||||
const newTop = Math.max(0, Math.min(maxH, initialTop + dy));
|
||||
lens.style.left = `${newLeft}px`;
|
||||
lens.style.top = `${newTop}px`;
|
||||
curX = Math.max(0, Math.min(maxW, e.clientX - startX));
|
||||
curY = Math.max(0, Math.min(maxH, e.clientY - startY));
|
||||
if (!rafId) {
|
||||
rafId = requestAnimationFrame(() => {
|
||||
lens.style.transform = `translate3d(${curX}px, ${curY}px, 0)`;
|
||||
rafId = null;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const stopDrag = (e) => {
|
||||
if (!isDragging) return;
|
||||
isDragging = false;
|
||||
try { lens.releasePointerCapture(e.pointerId); } catch(_) {}
|
||||
if (rafId) { cancelAnimationFrame(rafId); rafId = null; }
|
||||
lens.style.transform = `translate3d(${curX}px, ${curY}px, 0)`;
|
||||
lens.style.transition = 'transform 0.15s ease-out, box-shadow 0.2s ease';
|
||||
};
|
||||
|
||||
@@ -235,9 +237,11 @@ async function logout(){
|
||||
async function refresh(anim){
|
||||
if(!S.u)return;
|
||||
const[t,s,n,e,es]=await Promise.all(['tickets','stats','notifications','errors','errors/stats'].map(p=>api('/khira/api/'+p)));
|
||||
S.t=t.tickets||S.t;S.ts=s._f?S.ts:s;S.e=e.errors||S.e;S.es=es._f?S.es:es;S.n=n.notifications||S.n;
|
||||
const newT=t.tickets||S.t,newTs=s._f?S.ts:s,newE=e.errors||S.e,newEs=es._f?S.es:es,newN=n.notifications||S.n;
|
||||
const changed=anim||newT.length!==S.t.length||newE.length!==S.e.length||JSON.stringify(newTs)!==JSON.stringify(S.ts)||JSON.stringify(newEs)!==JSON.stringify(S.es);
|
||||
S.t=newT;S.ts=newTs;S.e=newE;S.es=newEs;S.n=newN;
|
||||
$('#dot').hidden=!S.n.some(x=>!x.read);
|
||||
render(anim);
|
||||
if(changed)render(anim);
|
||||
}
|
||||
const render=a=>S.sec==='tickets'?renderT(a):renderE(a);
|
||||
const tile=(n,l,k)=>`<button class="stat" data-k="${k}"><b>${n||0}</b><span>${l}</span></button>`;
|
||||
|
||||
Reference in New Issue
Block a user