MCPcopy
hub / github.com/hmjz100/LinkSwift / updatePosition

Function updatePosition

(改)网盘直链下载助手.user.js:3139–3161  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

3137
3138 // 更新位置
3139 var updatePosition = (x, y) => {
3140 if (!tooltip) return;
3141 let X = x + 10;
3142 let Y = y + 20;
3143 let clientWidth = document.documentElement.clientWidth;
3144 let clientHeight = document.documentElement.clientHeight;
3145 let scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
3146 let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
3147 if (X + tooltip.offsetWidth > clientWidth + scrollLeft) {
3148 X = clientWidth + scrollLeft - tooltip.offsetWidth;
3149 }
3150 if (X < scrollLeft) {
3151 X = scrollLeft;
3152 }
3153 if (Y + tooltip.offsetHeight > clientHeight + scrollTop) {
3154 Y = clientHeight + scrollTop - tooltip.offsetHeight;
3155 }
3156 if (Y < scrollTop) {
3157 Y = scrollTop;
3158 }
3159 // 使用 translate3d 的性能远高于 top/left,它不触发布局计算,还拥有 GPU 加速
3160 tooltip.style.transform = `translate3d(${X}px, ${Y}px, 0)`;
3161 };
3162
3163 // 内容渲染
3164 var renderContent = (target) => {

Callers 2

handleMoveFunction · 0.85
handleOverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected