Przeglądaj źródła

Significant mobile changes

The viewport attribute is now set, which should make mobile devices show it a bit
more correctly. I updated the bottom-names to be placed properly on mobile.
tags/v0.1.0
Fen Dweller 6 lat temu
rodzic
commit
707d7eaa88
3 zmienionych plików z 37 dodań i 30 usunięć
  1. +16
    -6
      macrovision.css
  2. +1
    -0
      macrovision.html
  3. +20
    -24
      macrovision.js

+ 16
- 6
macrovision.css Wyświetl plik

@@ -2,12 +2,15 @@


html { html {
height: 100%; height: 100%;
width: 100%;
box-sizing: border-box;
overflow-x: hidden; overflow-x: hidden;
overflow-y: hidden; overflow-y: hidden;
color: #eee; color: #eee;
} }


body { body {
position: relative;
background: #333; background: #333;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -80,8 +83,8 @@ body.toggle-entity-glow .entity-box:not(.selected) > img{


#options { #options {
position: relative; position: relative;
min-width: 200pt;
flex: 1 0 15vw;
flex: 1 1 15vw;
min-width: 140pt;
display: flex; display: flex;
justify-content: start; justify-content: start;
flex-direction: column; flex-direction: column;
@@ -211,7 +214,7 @@ body.show-extra-options .options-block.options-block-optional {


#world { #world {
position: relative; position: relative;
flex: 1 0 85vw;
flex: 1 1 85vw;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
} }
@@ -351,7 +354,8 @@ body.toggle-top-name .top-name.top-name-needed {
position: fixed; position: fixed;
width: 150px; width: 150px;
height: 50px; height: 50px;
transform: translate(-50%, 20pt);
z-index: 349539534;
transform: translate(-50%, 0pt);
} }


body.toggle-bottom-name .bottom-name { body.toggle-bottom-name .bottom-name {
@@ -360,7 +364,7 @@ body.toggle-bottom-name .bottom-name {


#menubar select { #menubar select {
max-width: 200pt; max-width: 200pt;
height: 60pt;
height: 40pt;
max-height: 180pt; max-height: 180pt;
overflow: hidden; overflow: hidden;
white-space: pre-wrap; white-space: pre-wrap;
@@ -387,7 +391,7 @@ body.toggle-bottom-name .bottom-name {
} }


#menubar button { #menubar button {
font-size: 48pt;
font-size: 36pt;
} }


#help { #help {
@@ -592,10 +596,16 @@ body.toggle-bottom-cover .bottom-cover {
.transitions { .transitions {
transition: 0.2s all; transition: 0.2s all;
} }

.rotate-forward { .rotate-forward {
transform: rotate(-90deg); transform: rotate(-90deg);
} }


.rotate-backward { .rotate-backward {
transform: rotate(90deg); transform: rotate(90deg);
}

i.fas
i.far {
pointer-events: none;
} }

+ 1
- 0
macrovision.html Wyświetl plik

@@ -19,6 +19,7 @@
<script src="presets/scenes.js"></script> <script src="presets/scenes.js"></script>
<script src="media/attribution.js"></script> <script src="media/attribution.js"></script>
<script src="macrovision.js"></script> <script src="macrovision.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=0.75, maximum-scale=0.75, user-scalable=0"/>
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<meta name="description" content="How big are they anyway?" /> <meta name="description" content="How big are they anyway?" />
<meta property="og:title" content="Macrovision" /> <meta property="og:title" content="Macrovision" />


+ 20
- 24
macrovision.js Wyświetl plik

@@ -131,7 +131,7 @@ function updateEntityElement(entity, element) {
const bottomName = document.querySelector("#bottom-name-" + element.dataset.key); const bottomName = document.querySelector("#bottom-name-" + element.dataset.key);


bottomName.style.left = position.x + entityX + "px"; bottomName.style.left = position.x + entityX + "px";
bottomName.style.top = "95vh";
bottomName.style.bottom = "0vh";
bottomName.innerText = entity.name; bottomName.innerText = entity.name;


const topName = document.querySelector("#top-name-" + element.dataset.key); const topName = document.querySelector("#top-name-" + element.dataset.key);
@@ -1000,6 +1000,14 @@ function toggleFullScreen() {
} }
} }


function handleResize() {
entityX = document.querySelector("#entities").getBoundingClientRect().x;
console.log(entityX)
canvasWidth = document.querySelector("#display").clientWidth - 100;
canvasHeight = document.querySelector("#display").clientHeight - 50;
updateSizes();
}

document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
prepareEntities(); prepareEntities();


@@ -1009,13 +1017,12 @@ document.addEventListener("DOMContentLoaded", () => {
sidebar.classList.remove("hidden"); sidebar.classList.remove("hidden");
e.target.classList.remove("rotate-forward"); e.target.classList.remove("rotate-forward");
e.target.classList.add("rotate-backward"); e.target.classList.add("rotate-backward");
updateSizes();
} else { } else {
sidebar.classList.add("hidden"); sidebar.classList.add("hidden");
e.target.classList.add("rotate-forward"); e.target.classList.add("rotate-forward");
e.target.classList.remove("rotate-backward"); e.target.classList.remove("rotate-backward");
updateSizes();
} }
handleResize();
}); });


document.querySelector("#menu-fullscreen").addEventListener("click", toggleFullScreen); document.querySelector("#menu-fullscreen").addEventListener("click", toggleFullScreen);
@@ -1341,6 +1348,16 @@ document.addEventListener("DOMContentLoaded", () => {
} }
}); });


window.addEventListener("resize", handleResize);

// TODO: further investigate why the tool initially starts out with wrong
// values under certain circumstances (seems to be narrow aspect ratios -
// maybe the menu bar is animating when it shouldn't)

setTimeout(handleResize, 250);


document.querySelector("#menu-permalink").addEventListener("click", e => { document.querySelector("#menu-permalink").addEventListener("click", e => {
linkScene(); linkScene();
}); });
@@ -1429,27 +1446,6 @@ function prepareEntities() {
}); });
} }


window.addEventListener("resize", () => {
entityX = document.querySelector("#entities").getBoundingClientRect().x;
console.log(entityX)
canvasWidth = document.querySelector("#display").clientWidth - 100;
canvasHeight = document.querySelector("#display").clientHeight - 50;
updateSizes();
})

// TODO: further investigate why the tool initially starts out with wrong
// values under certain circumstances (seems to be narrow aspect ratios -
// maybe the menu bar is animating when it shouldn't)

setTimeout(() => {
entityX = document.querySelector("#entities").getBoundingClientRect().x;
console.log(entityX)
canvasWidth = document.querySelector("#display").clientWidth - 100;
canvasHeight = document.querySelector("#display").clientHeight - 50;
updateSizes();
}, 250);

document.addEventListener("mousemove", (e) => { document.addEventListener("mousemove", (e) => {
if (clicked) { if (clicked) {
const position = snapRel(abs2rel({ x: e.clientX - dragOffsetX, y: e.clientY - dragOffsetY })); const position = snapRel(abs2rel({ x: e.clientX - dragOffsetX, y: e.clientY - dragOffsetY }));


Ładowanie…
Anuluj
Zapisz