mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 20:59:37 +08:00
feat: 默认工具栏在resize后自动调整位置
This commit is contained in:
parent
f52f986bfa
commit
361a6bafee
@ -37,7 +37,6 @@ function main() {
|
|||||||
floorNameLabel: document.getElementById('floorNameLabel'),
|
floorNameLabel: document.getElementById('floorNameLabel'),
|
||||||
statusBar: document.getElementById('statusBar'),
|
statusBar: document.getElementById('statusBar'),
|
||||||
status: document.getElementsByClassName('status'),
|
status: document.getElementsByClassName('status'),
|
||||||
toolBar: document.getElementById('toolBar'),
|
|
||||||
tools: document.getElementsByClassName('tools'),
|
tools: document.getElementsByClassName('tools'),
|
||||||
gameCanvas: document.getElementsByClassName('gameCanvas'),
|
gameCanvas: document.getElementsByClassName('gameCanvas'),
|
||||||
gif: document.getElementById('gif'),
|
gif: document.getElementById('gif'),
|
||||||
|
@ -427,3 +427,22 @@ Mota.require('var', 'hook').once('reset', () => {
|
|||||||
CustomToolbar.save();
|
CustomToolbar.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
const defaultsTool = CustomToolbar.list.find(v => v.id === '@defaults');
|
||||||
|
if (!defaultsTool) return;
|
||||||
|
// 计算位置
|
||||||
|
if (isMobile) {
|
||||||
|
// 手机端显示在最下方
|
||||||
|
defaultsTool.setPos(25, window.innerHeight - 100);
|
||||||
|
defaultsTool.setSize(window.innerWidth - 50, 100);
|
||||||
|
} else {
|
||||||
|
// 电脑显示在屏幕右方
|
||||||
|
const x = window.innerWidth / 2 + core.domStyle.scale * 240 + 75;
|
||||||
|
defaultsTool.setPos(x, window.innerHeight / 2 + 100);
|
||||||
|
defaultsTool.setSize(window.innerWidth - x - 75, 200);
|
||||||
|
}
|
||||||
|
defaultsTool.refresh(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user