Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alerts bug when using non-full-width position #19

Merged
merged 5 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions MMM-MBTA.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,36 @@
color: #5da9e8;
}

.alerts {
.MMM-MBTA .alerts-header {
margin-top: 6px;
}

.MMM-MBTA .alerts {
overflow: hidden;
max-width: 300px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

300px felt like a good max-width

}

.MMM-MBTA .alert-wrapper {
display: flex;
}

.MMM-MBTA .alert {
display: inline-block;
position: relative;
width: 100%;
height: 100%;
margin: 0;
/* start the alert off screen */
padding-left: 100%;
text-align: left;
white-space: nowrap;
/* Starting position */
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transform:translateX(100%);
/* Apply animation to this element */
-moz-animation: td 17s linear infinite;
-webkit-animation: td 17s linear infinite;
animation: td 17s linear infinite;
transform: translateX(0%);
animation: alert 17s linear infinite;
}

/* Move it (define the animation) */
@-moz-keyframes td {
0% { -moz-transform: translateX(100%); }
100% { -moz-transform: translateX(-100%); }
}
@-webkit-keyframes td {
0% { -webkit-transform: translateX(100%); }
100% { -webkit-transform: translateX(-100%); }
}
@keyframes td {
0% {
-moz-transform: translateX(100%); /* Firefox bug fix */
-webkit-transform: translateX(100%); /* Firefox bug fix */
transform: translateX(100%);
@keyframes alert {
0% {
transform: translateX(0%);
}
100% {
-moz-transform: translateX(-100%); /* Firefox bug fix */
-webkit-transform: translateX(-100%); /* Firefox bug fix */
transform: translateX(-100%);
edward-shen marked this conversation as resolved.
Show resolved Hide resolved

100% {
transform: translateX(-100%);
}
}
13 changes: 7 additions & 6 deletions MMM-MBTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,22 @@ Module.register("MMM-MBTA", {
wrapper.appendChild(alertTable);
} else if (uniqueAlerts.size > 0) {
var alertHeader = document.createElement("header");
alertHeader.className = "module-header alerts";
alertHeader.className = "module-header alerts-header";
alertHeader.innerHTML = "Alerts";
wrapper.appendChild(alertHeader);

var alertTable = document.createElement("table");
alertTable.className = "small";
var alertTable = document.createElement("div");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are tables common with MagicMirror modules? Got rid of it as it can cause annoying css behavior.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. It's been so long since I've written this. I'll just take your word for it, and it was probably the primary reason it's been so buggy as well?

alertTable.className = "alerts small";

for (let alert of uniqueAlerts) {
var alertText = alert;

var row = document.createElement("tr");
var row = document.createElement("div");
row.className = "alert-wrapper";
alertTable.appendChild(row);
alertTable.style.cssText = "width: inherit";
// alertTable.style.cssText = "width: inherit";

var alertCell = document.createElement("td");
var alertCell = document.createElement("div");
alertCell.innerHTML = alertText;
alertCell.className = "light small alert";
row.appendChild(alertCell);
Expand Down