Skip to content

Commit ce3006d

Browse files
committed
Support scrolling reading list content on page margins
1 parent 5eb419a commit ce3006d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

app/assets/javascripts/active_admin.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,22 @@ document.addEventListener("DOMContentLoaded", function () {
312312
if (perPageInput) perPageInput.value = this.perPage || "";
313313
if (daysInput) daysInput.value = this.days || "";
314314

315+
const contentEl = document.getElementById("reading-list-content");
316+
contentEl?.addEventListener(
317+
"wheel",
318+
(e) => {
319+
const iframe = contentEl.querySelector("iframe");
320+
if (!iframe || !iframe.contentWindow) return;
321+
try {
322+
iframe.contentWindow.scrollBy({ top: e.deltaY, left: e.deltaX });
323+
e.preventDefault();
324+
} catch (_) {
325+
// cross-origin iframe — can't scroll programmatically
326+
}
327+
},
328+
{ passive: false },
329+
);
330+
315331
perPageInput?.addEventListener("change", (e) => {
316332
const v = e.target.value.trim();
317333
this.perPage = v || null;
@@ -515,7 +531,8 @@ document.addEventListener("DOMContentLoaded", function () {
515531
iframe.srcdoc = '<base target="_blank">' + (data.description || "");
516532
iframe.style.cssText =
517533
"display:block;margin:0 auto;width:100%;max-width:950px;height:calc(100vh - 200px);border:none;";
518-
iframe.sandbox = "allow-popups allow-popups-to-escape-sandbox";
534+
iframe.sandbox =
535+
"allow-popups allow-popups-to-escape-sandbox allow-same-origin";
519536
contentDiv.appendChild(iframe);
520537
} else {
521538
contentDiv.innerHTML =

0 commit comments

Comments
 (0)