aboutsummaryrefslogtreecommitdiff
path: root/static/js/timeago.ts
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/timeago.ts')
-rw-r--r--static/js/timeago.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/static/js/timeago.ts b/static/js/timeago.ts
index 57eb16e..af8f6f5 100644
--- a/static/js/timeago.ts
+++ b/static/js/timeago.ts
@@ -8,7 +8,7 @@
style: "long",
});
- function viewport(element, options = { offset: 100 }) {
+ function viewport(element, options = { offset: 250 }) {
const view = element.getBoundingClientRect();
return view.top >= -options.offset
&& view.left >= -options.offset
@@ -45,14 +45,13 @@
if (element.dataset.type === "default") { tiny = function (string) { return string; }; }
if (element.dataset.type === "localDate") {
- return element.textContent = new Intl.DateTimeFormat([], {
- dateStyle: "medium",
- }).format(time).replace(",", "");
+ return element.textContent = new Intl.DateTimeFormat([], { dateStyle: "medium", }).format(time).replace(",", "");
}
if (element.dataset.type === "localTime") {
return element.textContent = new Intl.DateTimeFormat([], {
- hour12: false, timeStyle: "short",
+ hour12: false,
+ timeStyle: "short",
}).format(time) + " " + new Intl.DateTimeFormat([], { timeZoneName: "short" }).format(time).split(" ")[1];
}
@@ -78,8 +77,10 @@
const substitution = setInterval(date, 4);
- self.addEventListener("scroll", function () {
- date("viewport");
+ ["scroll", "URLChangedCustomEvent"].forEach(function (event) {
+ self.addEventListener(event, function () {
+ date("viewport");
+ });
});
self.addEventListener("DOMContentLoaded", function () {