Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bf0a1f1da | ||
|
|
1176c2009c | ||
|
|
30f97808ae |
@@ -34,6 +34,7 @@ JFVR 同时也是一个标准的 **Jellyfin 插件**,通过自建 Gitea 仓库
|
||||
| 脚本端点 | `/JFVR/jfvr.js`(bundle 内嵌在 DLL 里,URL 带内容哈希做缓存键) |
|
||||
| 状态查询 | `/JFVR/status` |
|
||||
| 设置页 | Dashboard → 插件 → Jellyfin Web VR(开关注入 / 覆盖脚本 URL) |
|
||||
| 页面按钮 | 「VR 播放」按钮**可拖动**(位置记住;双击回到默认右下角) |
|
||||
|
||||
**安装**:Dashboard → 插件 → 目录 → ⚙️ → ➕ → 粘贴上面的仓库地址 → 保存 →
|
||||
在 Catalog 里找到 **Jellyfin Web VR** → 安装 → **重启 Jellyfin**。
|
||||
@@ -128,6 +129,19 @@ localStorage['jfvr-cpt'] = 'off'; // 然后刷新,覆盖完全不安装
|
||||
|
||||
当前状态可以在诊断面板里看到(`canPlayType hook` 和 `HEVC real (decodingInfo)` 两段)。这也是 Meta 官方文档推荐的做法 —— 他们明确说「用 Media Capabilities API 探测,不要靠 UA 嗅探」。
|
||||
|
||||
### 1.4 「VR 播放」按钮可以拖了
|
||||
|
||||
原来钉死在右下角(`right:16px; bottom:120px`),窗口矮的时候正好压在播放看门狗弹窗的码率按钮上,没地方躲。
|
||||
|
||||
现在:
|
||||
|
||||
- 用 `left/top` 定位(不再用 `right/bottom`),用 pointer 事件拖动,位置记在 `localStorage['jfvr-btn-pos']`
|
||||
- `touch-action:none` —— 不加这个,触屏上拖动会变成滚动页面
|
||||
- **拖动结束仍然会触发一次 click**,代码会把那一次吃掉,所以拖完不会意外弹出面板
|
||||
- 限制在视窗内,窗口缩放时会重新夹紧
|
||||
- **双击回到默认右下角**(拖到尴尬位置时的逃生口)
|
||||
- 设置面板跟着按钮走(不再是钉在视窗角落),优先放在按钮上方,上方放不下就放下方,再放不下就夹在屏幕内
|
||||
|
||||
---
|
||||
|
||||
## 2. Quest 3 实测数据(已用 ADB + CDP 在真机验证)
|
||||
|
||||
Vendored
+158
-5
@@ -5219,16 +5219,23 @@
|
||||
// Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it
|
||||
// covered the player's fullscreen button (owner report). 120 px clears the
|
||||
// OSD bottom bar; the settings panel stacks above it.
|
||||
'.jfvr-btn{position:fixed;right:16px;bottom:120px;z-index:2147483000;display:flex;align-items:center;gap:8px;',
|
||||
// left/top are set from JS (see placeButton) so the button can be dragged
|
||||
// anywhere. touch-action:none is what makes a drag work on a touch screen
|
||||
// instead of scrolling the page underneath.
|
||||
'.jfvr-btn{position:fixed;z-index:2147483000;display:flex;align-items:center;gap:8px;',
|
||||
'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;',
|
||||
'font-size:15px;font-weight:600;cursor:pointer;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit}',
|
||||
'font-size:15px;font-weight:600;cursor:grab;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit;',
|
||||
'touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}',
|
||||
'.jfvr-btn:active{transform:scale(.96)}',
|
||||
'.jfvr-btn.jfvr-drag{cursor:grabbing;transform:none;box-shadow:0 10px 32px rgba(0,0,0,.65)}',
|
||||
// the panel must always fit the viewport AND keep the CTA reachable, so the
|
||||
// body scrolls and the button lives in a sticky footer
|
||||
'.jfvr-panel{position:fixed;right:16px;bottom:180px;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
|
||||
// Positioned from JS (positionPanel) so it follows the button once the
|
||||
// button has been dragged; it no longer lives in the viewport corner.
|
||||
'.jfvr-panel{position:fixed;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
|
||||
'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);',
|
||||
'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;',
|
||||
'max-height:calc(100vh - 200px);overflow:hidden}',
|
||||
'max-height:calc(100vh - 32px);overflow:hidden}',
|
||||
'.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}',
|
||||
'.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}',
|
||||
'.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}',
|
||||
@@ -5276,9 +5283,151 @@
|
||||
var b = NS.makeEl('button', 'jfvr-btn');
|
||||
b.type = 'button';
|
||||
b.innerHTML = '<span>🎥</span><span>VR 播放</span>';
|
||||
b.addEventListener('click', function (ev) { ev.stopPropagation(); togglePanel(); });
|
||||
b.title = '点击打开设置;按住拖动可以换位置;双击回到默认位置';
|
||||
b.addEventListener('click', function (ev) {
|
||||
ev.stopPropagation();
|
||||
// A drag still produces a click on most browsers. Swallow that one so
|
||||
// dragging the button never opens the panel by accident.
|
||||
if (dragMoved) { dragMoved = false; return; }
|
||||
togglePanel();
|
||||
});
|
||||
// Escape hatch: a button dragged half off a small window is annoying to
|
||||
// recover by hand.
|
||||
b.addEventListener('dblclick', function (ev) {
|
||||
ev.stopPropagation();
|
||||
resetButtonPos();
|
||||
});
|
||||
installDrag(b);
|
||||
document.body.appendChild(b);
|
||||
btn = b;
|
||||
btnPos = readBtnPos();
|
||||
placeButton(b, btnPos);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* button placement / dragging
|
||||
* ------------------------------------------------------------------
|
||||
* The button used to be pinned to the bottom-right corner. On a short window
|
||||
* that put it right on top of the bitrate choices the playback watchdog
|
||||
* shows (that panel is centred), and there was no way to move it. It is
|
||||
* draggable now and the spot is remembered per browser.
|
||||
*
|
||||
* The settings panel follows the button rather than the viewport corner, so
|
||||
* the two cannot drift apart.
|
||||
* ------------------------------------------------------------------ */
|
||||
var BTN_POS_KEY = 'jfvr-btn-pos';
|
||||
var BTN_MARGIN = 8;
|
||||
var DRAG_SLOP = 4; // px of travel before it counts as a drag, not a tap
|
||||
|
||||
var btnPos = null; // {left, top} once placed; persisted on drop
|
||||
var dragging = false;
|
||||
var dragMoved = false;
|
||||
var dragStart = null;
|
||||
|
||||
function readBtnPos() {
|
||||
try {
|
||||
var o = JSON.parse(localStorage.getItem(BTN_POS_KEY) || 'null');
|
||||
if (o && typeof o.left === 'number' && typeof o.top === 'number') return o;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
function writeBtnPos(pos) {
|
||||
try { localStorage.setItem(BTN_POS_KEY, JSON.stringify(pos)); } catch (e) {}
|
||||
}
|
||||
|
||||
function clampPos(left, top, w, h) {
|
||||
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
|
||||
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
|
||||
return {
|
||||
left: Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)),
|
||||
top: Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop))
|
||||
};
|
||||
}
|
||||
|
||||
/** The default spot: the old fixed corner, expressed in left/top. */
|
||||
function defaultPos(b) {
|
||||
return { left: window.innerWidth - b.offsetWidth - 16,
|
||||
top: window.innerHeight - b.offsetHeight - 120 };
|
||||
}
|
||||
|
||||
function placeButton(b, pos) {
|
||||
var p = pos || defaultPos(b);
|
||||
var c = clampPos(p.left, p.top, b.offsetWidth, b.offsetHeight);
|
||||
b.style.left = c.left + 'px';
|
||||
b.style.top = c.top + 'px';
|
||||
b.style.right = 'auto';
|
||||
b.style.bottom = 'auto';
|
||||
return c;
|
||||
}
|
||||
|
||||
function resetButtonPos() {
|
||||
if (!btn) return;
|
||||
try { localStorage.removeItem(BTN_POS_KEY); } catch (e) {}
|
||||
btnPos = placeButton(btn, null);
|
||||
positionPanel();
|
||||
}
|
||||
|
||||
function installDrag(b) {
|
||||
b.addEventListener('pointerdown', function (ev) {
|
||||
if (ev.button != null && ev.button !== 0) return; // primary button / touch only
|
||||
var r = b.getBoundingClientRect();
|
||||
dragging = true;
|
||||
dragMoved = false;
|
||||
dragStart = { x: ev.clientX, y: ev.clientY, left: r.left, top: r.top };
|
||||
b.classList.add('jfvr-drag');
|
||||
try { b.setPointerCapture(ev.pointerId); } catch (e) {}
|
||||
});
|
||||
|
||||
b.addEventListener('pointermove', function (ev) {
|
||||
if (!dragging || !dragStart) return;
|
||||
var dx = ev.clientX - dragStart.x;
|
||||
var dy = ev.clientY - dragStart.y;
|
||||
if (!dragMoved) {
|
||||
if (Math.abs(dx) < DRAG_SLOP && Math.abs(dy) < DRAG_SLOP) return;
|
||||
dragMoved = true;
|
||||
if (panel) hidePanel(); // do not drag the panel around with it
|
||||
}
|
||||
btnPos = clampPos(dragStart.left + dx, dragStart.top + dy, b.offsetWidth, b.offsetHeight);
|
||||
b.style.left = btnPos.left + 'px';
|
||||
b.style.top = btnPos.top + 'px';
|
||||
});
|
||||
|
||||
function endDrag(ev) {
|
||||
if (!dragging) return;
|
||||
dragging = false;
|
||||
dragStart = null;
|
||||
b.classList.remove('jfvr-drag');
|
||||
try { b.releasePointerCapture(ev.pointerId); } catch (e) {}
|
||||
if (dragMoved) writeBtnPos(btnPos);
|
||||
}
|
||||
b.addEventListener('pointerup', endDrag);
|
||||
b.addEventListener('pointercancel', endDrag);
|
||||
}
|
||||
|
||||
/** Put the panel next to the button: above it, or below when there is no room. */
|
||||
function positionPanel() {
|
||||
if (!panel || !btn) return;
|
||||
var b = btn.getBoundingClientRect();
|
||||
var w = panel.offsetWidth;
|
||||
var h = panel.offsetHeight;
|
||||
var gap = 8;
|
||||
|
||||
var left = b.right - w; // right edges aligned
|
||||
var top = b.top - h - gap;
|
||||
if (top < BTN_MARGIN) top = b.bottom + gap; // no room above -> below
|
||||
|
||||
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
|
||||
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
|
||||
panel.style.left = Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)) + 'px';
|
||||
panel.style.top = Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop)) + 'px';
|
||||
panel.style.right = 'auto';
|
||||
panel.style.bottom = 'auto';
|
||||
}
|
||||
|
||||
function onViewportResize() {
|
||||
if (btn && document.body.contains(btn)) btnPos = placeButton(btn, btnPos);
|
||||
positionPanel();
|
||||
}
|
||||
|
||||
function removeButton() {
|
||||
@@ -5462,6 +5611,7 @@
|
||||
panel.appendChild(foot);
|
||||
|
||||
document.body.appendChild(panel);
|
||||
positionPanel();
|
||||
|
||||
panelSync = function () {
|
||||
for (var i = 0; i < panelSyncs.length; i++) {
|
||||
@@ -6873,6 +7023,9 @@
|
||||
window.addEventListener('beforeunload', function () {
|
||||
if (S.session) { try { S.session.end(); } catch (e) {} }
|
||||
});
|
||||
// Keep the draggable button (and the panel that follows it) on screen when
|
||||
// the window changes size.
|
||||
window.addEventListener('resize', onViewportResize);
|
||||
installFrameTracker();
|
||||
|
||||
window.__JFVR_STATE__ = S;
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
"owner": "cat-shark",
|
||||
"category": "General",
|
||||
"versions": [
|
||||
{
|
||||
"version": "0.4.0.0",
|
||||
"targetAbi": "12.0.0.0",
|
||||
"changelog": "Bundle version: `ae28bd`\n\nFirst plugin build. The web bundle is embedded in the DLL and served from /JFVR/jfvr.js; index.html is rewritten at request time, so nothing is written to the jellyfin-web folder on disk.",
|
||||
"sourceUrl": "https://git.cat-shark.xyz/cat-shark/jellyfin_vr_web_plugin/releases/download/v0.4.0.0/Jellyfin.Plugin.JFVR_12.0.0.0.zip",
|
||||
"checksum": "30A0E388FFD6A3D88C73DAB5928C6388",
|
||||
"timestamp": "2026-10-17T17:20:34"
|
||||
},
|
||||
{
|
||||
"version": "0.3.0.0",
|
||||
"targetAbi": "12.0.0.0",
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
# (InstallationManager.GetAvailablePackages), so one package covers all of 12.x.
|
||||
name: "Jellyfin Web VR"
|
||||
guid: "7d33ef59-f9b0-412b-93bd-5cd5353018de"
|
||||
version: "0.3.0.0"
|
||||
version: "0.4.0.0"
|
||||
targetAbi: "12.0.0.0"
|
||||
framework: "net10.0"
|
||||
overview: "VR180/VR360 playback inside Jellyfin Web for Meta Quest 3."
|
||||
|
||||
+158
-5
@@ -299,16 +299,23 @@
|
||||
// Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it
|
||||
// covered the player's fullscreen button (owner report). 120 px clears the
|
||||
// OSD bottom bar; the settings panel stacks above it.
|
||||
'.jfvr-btn{position:fixed;right:16px;bottom:120px;z-index:2147483000;display:flex;align-items:center;gap:8px;',
|
||||
// left/top are set from JS (see placeButton) so the button can be dragged
|
||||
// anywhere. touch-action:none is what makes a drag work on a touch screen
|
||||
// instead of scrolling the page underneath.
|
||||
'.jfvr-btn{position:fixed;z-index:2147483000;display:flex;align-items:center;gap:8px;',
|
||||
'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;',
|
||||
'font-size:15px;font-weight:600;cursor:pointer;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit}',
|
||||
'font-size:15px;font-weight:600;cursor:grab;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit;',
|
||||
'touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}',
|
||||
'.jfvr-btn:active{transform:scale(.96)}',
|
||||
'.jfvr-btn.jfvr-drag{cursor:grabbing;transform:none;box-shadow:0 10px 32px rgba(0,0,0,.65)}',
|
||||
// the panel must always fit the viewport AND keep the CTA reachable, so the
|
||||
// body scrolls and the button lives in a sticky footer
|
||||
'.jfvr-panel{position:fixed;right:16px;bottom:180px;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
|
||||
// Positioned from JS (positionPanel) so it follows the button once the
|
||||
// button has been dragged; it no longer lives in the viewport corner.
|
||||
'.jfvr-panel{position:fixed;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
|
||||
'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);',
|
||||
'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;',
|
||||
'max-height:calc(100vh - 200px);overflow:hidden}',
|
||||
'max-height:calc(100vh - 32px);overflow:hidden}',
|
||||
'.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}',
|
||||
'.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}',
|
||||
'.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}',
|
||||
@@ -356,9 +363,151 @@
|
||||
var b = NS.makeEl('button', 'jfvr-btn');
|
||||
b.type = 'button';
|
||||
b.innerHTML = '<span>🎥</span><span>VR 播放</span>';
|
||||
b.addEventListener('click', function (ev) { ev.stopPropagation(); togglePanel(); });
|
||||
b.title = '点击打开设置;按住拖动可以换位置;双击回到默认位置';
|
||||
b.addEventListener('click', function (ev) {
|
||||
ev.stopPropagation();
|
||||
// A drag still produces a click on most browsers. Swallow that one so
|
||||
// dragging the button never opens the panel by accident.
|
||||
if (dragMoved) { dragMoved = false; return; }
|
||||
togglePanel();
|
||||
});
|
||||
// Escape hatch: a button dragged half off a small window is annoying to
|
||||
// recover by hand.
|
||||
b.addEventListener('dblclick', function (ev) {
|
||||
ev.stopPropagation();
|
||||
resetButtonPos();
|
||||
});
|
||||
installDrag(b);
|
||||
document.body.appendChild(b);
|
||||
btn = b;
|
||||
btnPos = readBtnPos();
|
||||
placeButton(b, btnPos);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* button placement / dragging
|
||||
* ------------------------------------------------------------------
|
||||
* The button used to be pinned to the bottom-right corner. On a short window
|
||||
* that put it right on top of the bitrate choices the playback watchdog
|
||||
* shows (that panel is centred), and there was no way to move it. It is
|
||||
* draggable now and the spot is remembered per browser.
|
||||
*
|
||||
* The settings panel follows the button rather than the viewport corner, so
|
||||
* the two cannot drift apart.
|
||||
* ------------------------------------------------------------------ */
|
||||
var BTN_POS_KEY = 'jfvr-btn-pos';
|
||||
var BTN_MARGIN = 8;
|
||||
var DRAG_SLOP = 4; // px of travel before it counts as a drag, not a tap
|
||||
|
||||
var btnPos = null; // {left, top} once placed; persisted on drop
|
||||
var dragging = false;
|
||||
var dragMoved = false;
|
||||
var dragStart = null;
|
||||
|
||||
function readBtnPos() {
|
||||
try {
|
||||
var o = JSON.parse(localStorage.getItem(BTN_POS_KEY) || 'null');
|
||||
if (o && typeof o.left === 'number' && typeof o.top === 'number') return o;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
function writeBtnPos(pos) {
|
||||
try { localStorage.setItem(BTN_POS_KEY, JSON.stringify(pos)); } catch (e) {}
|
||||
}
|
||||
|
||||
function clampPos(left, top, w, h) {
|
||||
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
|
||||
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
|
||||
return {
|
||||
left: Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)),
|
||||
top: Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop))
|
||||
};
|
||||
}
|
||||
|
||||
/** The default spot: the old fixed corner, expressed in left/top. */
|
||||
function defaultPos(b) {
|
||||
return { left: window.innerWidth - b.offsetWidth - 16,
|
||||
top: window.innerHeight - b.offsetHeight - 120 };
|
||||
}
|
||||
|
||||
function placeButton(b, pos) {
|
||||
var p = pos || defaultPos(b);
|
||||
var c = clampPos(p.left, p.top, b.offsetWidth, b.offsetHeight);
|
||||
b.style.left = c.left + 'px';
|
||||
b.style.top = c.top + 'px';
|
||||
b.style.right = 'auto';
|
||||
b.style.bottom = 'auto';
|
||||
return c;
|
||||
}
|
||||
|
||||
function resetButtonPos() {
|
||||
if (!btn) return;
|
||||
try { localStorage.removeItem(BTN_POS_KEY); } catch (e) {}
|
||||
btnPos = placeButton(btn, null);
|
||||
positionPanel();
|
||||
}
|
||||
|
||||
function installDrag(b) {
|
||||
b.addEventListener('pointerdown', function (ev) {
|
||||
if (ev.button != null && ev.button !== 0) return; // primary button / touch only
|
||||
var r = b.getBoundingClientRect();
|
||||
dragging = true;
|
||||
dragMoved = false;
|
||||
dragStart = { x: ev.clientX, y: ev.clientY, left: r.left, top: r.top };
|
||||
b.classList.add('jfvr-drag');
|
||||
try { b.setPointerCapture(ev.pointerId); } catch (e) {}
|
||||
});
|
||||
|
||||
b.addEventListener('pointermove', function (ev) {
|
||||
if (!dragging || !dragStart) return;
|
||||
var dx = ev.clientX - dragStart.x;
|
||||
var dy = ev.clientY - dragStart.y;
|
||||
if (!dragMoved) {
|
||||
if (Math.abs(dx) < DRAG_SLOP && Math.abs(dy) < DRAG_SLOP) return;
|
||||
dragMoved = true;
|
||||
if (panel) hidePanel(); // do not drag the panel around with it
|
||||
}
|
||||
btnPos = clampPos(dragStart.left + dx, dragStart.top + dy, b.offsetWidth, b.offsetHeight);
|
||||
b.style.left = btnPos.left + 'px';
|
||||
b.style.top = btnPos.top + 'px';
|
||||
});
|
||||
|
||||
function endDrag(ev) {
|
||||
if (!dragging) return;
|
||||
dragging = false;
|
||||
dragStart = null;
|
||||
b.classList.remove('jfvr-drag');
|
||||
try { b.releasePointerCapture(ev.pointerId); } catch (e) {}
|
||||
if (dragMoved) writeBtnPos(btnPos);
|
||||
}
|
||||
b.addEventListener('pointerup', endDrag);
|
||||
b.addEventListener('pointercancel', endDrag);
|
||||
}
|
||||
|
||||
/** Put the panel next to the button: above it, or below when there is no room. */
|
||||
function positionPanel() {
|
||||
if (!panel || !btn) return;
|
||||
var b = btn.getBoundingClientRect();
|
||||
var w = panel.offsetWidth;
|
||||
var h = panel.offsetHeight;
|
||||
var gap = 8;
|
||||
|
||||
var left = b.right - w; // right edges aligned
|
||||
var top = b.top - h - gap;
|
||||
if (top < BTN_MARGIN) top = b.bottom + gap; // no room above -> below
|
||||
|
||||
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
|
||||
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
|
||||
panel.style.left = Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)) + 'px';
|
||||
panel.style.top = Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop)) + 'px';
|
||||
panel.style.right = 'auto';
|
||||
panel.style.bottom = 'auto';
|
||||
}
|
||||
|
||||
function onViewportResize() {
|
||||
if (btn && document.body.contains(btn)) btnPos = placeButton(btn, btnPos);
|
||||
positionPanel();
|
||||
}
|
||||
|
||||
function removeButton() {
|
||||
@@ -542,6 +691,7 @@
|
||||
panel.appendChild(foot);
|
||||
|
||||
document.body.appendChild(panel);
|
||||
positionPanel();
|
||||
|
||||
panelSync = function () {
|
||||
for (var i = 0; i < panelSyncs.length; i++) {
|
||||
@@ -1953,6 +2103,9 @@
|
||||
window.addEventListener('beforeunload', function () {
|
||||
if (S.session) { try { S.session.end(); } catch (e) {} }
|
||||
});
|
||||
// Keep the draggable button (and the panel that follows it) on screen when
|
||||
// the window changes size.
|
||||
window.addEventListener('resize', onViewportResize);
|
||||
installFrameTracker();
|
||||
|
||||
window.__JFVR_STATE__ = S;
|
||||
|
||||
Reference in New Issue
Block a user