tweak animations

master
Bryan 2024-08-03 01:16:26 -06:00
parent 246360efc1
commit 73562b08f0
1 changed files with 9 additions and 6 deletions

View File

@ -223,9 +223,8 @@ const showText = function(showAll) {
const removeMessage = function() { const removeMessage = function() {
const removeAndReset = () => { const removeAndReset = () => {
const id = msgBoxes[messageNum].msg.id; const id = msgBoxes[messageNum].msg.id;
const idx = Bangle.findIndex(m => m.id === id); const idx = Bangle.MESSAGES.findIndex(m => m.id === id);
Bangle.MESSAGES.splice(idx, 1); // remove from Bangle.MESSAGES Bangle.MESSAGES.splice(idx, 1); // remove from Bangle.MESSAGES
//Bangle.MESSAGES = Bangle.MESSAGES.filter(m => m.id !== id); // remove from Bangle.MESSAGES
msgBoxes.splice(messageNum, 1); // remove from msgBoxes msgBoxes.splice(messageNum, 1); // remove from msgBoxes
if (!msgBoxes.length) { if (!msgBoxes.length) {
Bangle.setUI(); Bangle.setUI();
@ -268,9 +267,10 @@ const showText = function(showAll) {
} }
firstTouch = true; firstTouch = true;
return new Promise((resolve, _reject) => { return new Promise((resolve, _reject) => {
let multiplier = 1;
let animate = () => { let animate = () => {
msgBoxes[messageNum].yOffset -= step; msgBoxes[messageNum].yOffset -= step * multiplier;
msgBoxes[messageNum + 1].yOffset -= step; msgBoxes[messageNum + 1].yOffset -= step * multiplier;
if (msgBoxes[messageNum + 1].yOffset <= 0) { if (msgBoxes[messageNum + 1].yOffset <= 0) {
if (!removeCurrent) { if (!removeCurrent) {
if (messageNum < msgBoxes.length) { if (messageNum < msgBoxes.length) {
@ -285,6 +285,7 @@ const showText = function(showAll) {
msgBoxes[messageNum].draw(); msgBoxes[messageNum].draw();
msgBoxes[messageNum + 1].draw(); msgBoxes[messageNum + 1].draw();
drawFooter(); drawFooter();
multiplier *= 2;
timeouts.animID = setTimeout(animate, delay); timeouts.animID = setTimeout(animate, delay);
} }
}; };
@ -300,9 +301,10 @@ const showText = function(showAll) {
} }
firstTouch = true; firstTouch = true;
return new Promise((resolve, _reject) => { return new Promise((resolve, _reject) => {
let multiplier = 1;
let animate = () => { let animate = () => {
msgBoxes[messageNum].yOffset += step; msgBoxes[messageNum].yOffset += step * multiplier;
msgBoxes[messageNum - 1].yOffset += step; msgBoxes[messageNum - 1].yOffset += step * multiplier;
if (msgBoxes[messageNum - 1].yOffset >= 0) { if (msgBoxes[messageNum - 1].yOffset >= 0) {
if (!removeCurrent) { if (!removeCurrent) {
if (messageNum > 0) { if (messageNum > 0) {
@ -317,6 +319,7 @@ const showText = function(showAll) {
msgBoxes[messageNum].draw(); msgBoxes[messageNum].draw();
msgBoxes[messageNum - 1].draw(); msgBoxes[messageNum - 1].draw();
drawFooter(); drawFooter();
multiplier *= 2;
timeouts.animID = setTimeout(animate, delay); timeouts.animID = setTimeout(animate, delay);
} }
}; };