forked from olcxjas-softworks/LarpixClient
Add test mobile ui
This commit is contained in:
parent
d29c5eea74
commit
34ddd1d507
8 changed files with 356 additions and 190 deletions
|
|
@ -685,19 +685,20 @@ function showFixedContextMenu(rect, html) {
|
|||
|
||||
fixedContextMenu.classList.add("show");
|
||||
}
|
||||
async function switchRoomContent(title, content, showRoomBar, icon = "")
|
||||
async function switchRoomContent(title, content, showRoomBar, icon = "", skipMobileSlide = false)
|
||||
{
|
||||
roomContentMain.style.transform = "scale(0.85)";
|
||||
roomContentMain.style.opacity = "0";
|
||||
await delay(200);
|
||||
let backBtnHtml = `<button class="mobile-nav-btn" onclick="mobileNavBack()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg></button>`;
|
||||
let detailsBtnHtml = showRoomBar ? `<button class="mobile-nav-btn right" onclick="mobileNavDetails()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></button>` : '';
|
||||
|
||||
roomTopBar.innerHTML = `${icon}<space></space><inherit>${processBlah(title)}</inherit>`
|
||||
roomTopBar.innerHTML = `${backBtnHtml}${icon}<space></space><inherit>${processBlah(title)}</inherit><div class="flex-spacer"></div>${detailsBtnHtml}`;
|
||||
roomDetailsBar.style.display = showRoomBar ? "flex" : "none";
|
||||
|
||||
//content blah parsing
|
||||
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString(content, "text/html");
|
||||
|
||||
|
||||
let blahTags = doc.getElementsByTagName("blah");
|
||||
for (let i = 0; i < blahTags.length; i++) {
|
||||
blahTags[i].innerHTML = processBlah(blahTags[i].innerHTML);
|
||||
|
|
@ -714,14 +715,18 @@ async function switchRoomContent(title, content, showRoomBar, icon = "")
|
|||
let value = placeholders[i].placeholder.split("{blah(")[1].split(")}")[0];
|
||||
placeholders[i].placeholder = processBlah(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
roomContentMain.innerHTML = doc.body.innerHTML;
|
||||
|
||||
|
||||
|
||||
roomContentMain.style.transform = "";
|
||||
roomContentMain.style.opacity = "";
|
||||
|
||||
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
if (window.innerWidth <= 52 * rem && !skipMobileSlide) {
|
||||
mainScreen.classList.remove('mobile-details');
|
||||
mainScreen.classList.add('mobile-content');
|
||||
}
|
||||
}
|
||||
collapseDmsBtn.addEventListener("click", () => {
|
||||
collapseDmsBtn.classList.toggle("collapsed");
|
||||
|
|
@ -799,32 +804,44 @@ function setActiveSidebarIndicator(element, skipDisabling = false)
|
|||
element.classList.add("active");
|
||||
}
|
||||
|
||||
/* replaced with css
|
||||
sidebarHomeButton.addEventListener("mouseenter", () => {
|
||||
sidebarHomeIndicator.classList.add("hover");
|
||||
function mobileNavBack() {
|
||||
if(mainScreen.classList.contains('mobile-details')) {
|
||||
mainScreen.classList.remove('mobile-details');
|
||||
mainScreen.classList.add('mobile-content');
|
||||
} else {
|
||||
mainScreen.classList.remove('mobile-content');
|
||||
}
|
||||
}
|
||||
function mobileNavDetails() {
|
||||
mainScreen.classList.add('mobile-details');
|
||||
}
|
||||
let touchStartX = 0;
|
||||
let touchEndX = 0;
|
||||
let touchStartY = 0;
|
||||
let touchEndY = 0;
|
||||
document.addEventListener('touchstart', e => {
|
||||
touchStartX = e.changedTouches[0].screenX;
|
||||
touchStartY = e.changedTouches[0].screenY;
|
||||
});
|
||||
sidebarHomeButton.addEventListener("mouseleave", () => {
|
||||
sidebarHomeIndicator.classList.remove("hover");
|
||||
document.addEventListener('touchend', e => {
|
||||
touchEndX = e.changedTouches[0].screenX;
|
||||
touchEndY = e.changedTouches[0].screenY;
|
||||
handleMobileSwipe();
|
||||
});
|
||||
function handleMobileSwipe() {
|
||||
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
if (window.innerWidth > 52 * rem) return;
|
||||
|
||||
sidebarAddButton.addEventListener("mouseenter", () => {
|
||||
sidebarAddIndicator.classList.add("hover");
|
||||
});
|
||||
sidebarAddButton.addEventListener("mouseleave", () => {
|
||||
sidebarAddIndicator.classList.remove("hover");
|
||||
});
|
||||
let diffX = touchEndX - touchStartX;
|
||||
let diffY = touchEndY - touchStartY;
|
||||
|
||||
sidebarProfileButton.addEventListener("mouseenter", () => {
|
||||
sidebarProfileIndicator.classList.add("hover");
|
||||
});
|
||||
sidebarProfileButton.addEventListener("mouseleave", () => {
|
||||
sidebarProfileIndicator.classList.remove("hover");
|
||||
});
|
||||
|
||||
sidebarInboxButton.addEventListener("mouseenter", () => {
|
||||
sidebarInboxIndicator.classList.add("hover");
|
||||
});
|
||||
sidebarInboxButton.addEventListener("mouseleave", () => {
|
||||
sidebarInboxIndicator.classList.remove("hover");
|
||||
});
|
||||
*/
|
||||
if (Math.abs(diffX) > Math.abs(diffY) && Math.abs(diffX) > 60) {
|
||||
if (diffX > 0) {
|
||||
mobileNavBack();
|
||||
} else {
|
||||
if (mainScreen.classList.contains('mobile-content') && roomDetailsBar.style.display !== 'none') {
|
||||
mobileNavDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue