Browse Source

Made the popups prettier

tags/v0.0.1
Fen Dweller 7 years ago
parent
commit
3439566ec1
2 changed files with 37 additions and 8 deletions
  1. +31
    -5
      gorge.css
  2. +6
    -3
      gorge.js

+ 31
- 5
gorge.css View File

@@ -256,18 +256,44 @@ button {
margin: -25px -50px; margin: -25px -50px;
} }


.click-popup {
.click-popup-food {
pointer-events: none;
transform-origin: -100% 50%;
text-align: center;
position: fixed;
animation: click-popup-food 2s linear;
animation-fill-mode: both;
font-size: 36px;
}

.click-popup-gulp {
pointer-events: none;
transform-origin: -100% 50%;
text-align: center;
position: fixed; position: fixed;
animation: click-popup 2s linear;
animation: click-popup-gulp 2s linear;
animation-fill-mode: both;
font-size: 36px;
}

@keyframes click-popup-food {
0% {
transform: translate(0px, 0px) scale(1, 1);
opacity: 1;
}
100% {
transform: translate(0px, -200px) scale(0.5, 0.5);
opacity: 0;
}
} }


@keyframes click-popup {
@keyframes click-popup-gulp {
0% { 0% {
transform: translate(0px, 0px);
transform: translate(0px, 0px) scale(1, 1);
opacity: 1; opacity: 1;
} }
100% { 100% {
transform: translate(0px, -200px);
transform: translate(0px, 200px) scale(0.5, 0.5);
opacity: 0; opacity: 0;
} }
} }

+ 6
- 3
gorge.js View File

@@ -322,7 +322,10 @@ function initializeData() {
function registerListeners() { function registerListeners() {
document.querySelector("#tasty-micro").addEventListener("click", (e) => { document.querySelector("#tasty-micro").addEventListener("click", (e) => {
const add = eatMicro(); const add = eatMicro();
clickPopup("+" + round(add, 1) + " food", [e.clientX, e.clientY]);
const text = "+" + round(add, 1) + " food";
const gulp = "*glp*";
clickPopup(text, "food", [e.clientX, e.clientY]);
clickPopup(gulp, "gulp", [e.clientX, e.clientY]);
}); });


document.querySelector("#save").addEventListener("click", save); document.querySelector("#save").addEventListener("click", save);
@@ -539,11 +542,11 @@ function renderEffects(effectList) {
return renderLines(list); return renderLines(list);
} }


function clickPopup(text, location) {
function clickPopup(text, type, location) {
const div = document.createElement("div"); const div = document.createElement("div");
div.textContent = text; div.textContent = text;


div.classList.add("click-popup");
div.classList.add("click-popup-" + type);


div.style.left = location[0] + "px"; div.style.left = location[0] + "px";
div.style.top = location[1] + "px"; div.style.top = location[1] + "px";


Loading…
Cancel
Save