-
🌐 async-utils.jsWeb, 3.69 kB⬇
-
🌐 auth-storage.jsWeb, 735 B⬇
-
🌐 chat-helpers.jsWeb, 8.85 kB⬇
-
🌐 chat-renderer.jsWeb, 70.00 kB⬇
-
🌐 code-overlay.jsWeb, 21.77 kB⬇
-
🌐 confirm-dialog.jsWeb, 3.17 kB⬇
-
🌐 conversation-format-utils.jsWeb, 21.51 kB⬇
-
🌐 diagram-overlay.jsWeb, 7.93 kB⬇
-
🌐 dialog.jsWeb, 2.50 kB⬇
-
🌐 dom-utils.jsWeb, 8.33 kB⬇
-
🌐 drag-reorder.jsWeb, 4.82 kB⬇
-
🌐 elements.jsWeb, 11.06 kB⬇
-
🌐 export-utils.jsWeb, 1.53 kB⬇
-
🌐 format-utils.jsWeb, 29.60 kB⬇
-
🌐 history-navigation.jsWeb, 1.95 kB⬇
-
🌐 hljs-yaml.jsWeb, 5.07 kB⬇
-
🌐 inline-format.jsWeb, 7.35 kB⬇
-
🌐 instant-answer.jsWeb, 19.82 kB⬇
-
🌐 interactive-tools.jsWeb, 38.77 kB⬇
-
🌐 mermaid-fixes.jsWeb, 4.60 kB⬇
-
🌐 mermaid-render.jsWeb, 5.10 kB⬇
-
🌐 mermaid.jsWeb, 195 B⬇
-
🌐 migrations.jsWeb, 12.11 kB⬇
-
🌐 multi-choice-dialog.jsWeb, 1.33 kB⬇
-
🌐 notification-stack.jsWeb, 2.50 kB⬇
-
🌐 options-manager.jsWeb, 45.56 kB⬇
-
🌐 overlay-utils.jsWeb, 4.14 kB⬇
-
🌐 pdf-export.jsWeb, 23.59 kB⬇
-
🌐 pinch-zoom.jsWeb, 3.21 kB⬇
-
🌐 plugin-dialog.jsWeb, 2.17 kB⬇
-
🌐 read-aloud.jsWeb, 33.84 kB⬇
-
🌐 response-pipeline.jsWeb, 55.19 kB⬇
-
🌐 scratchpad-editor.jsWeb, 8.64 kB⬇
-
🌐 scratchpad-export.jsWeb, 3.56 kB⬇
-
🌐 scrollbars.jsWeb, 3.12 kB⬇
-
🌐 selection-manager.jsWeb, 3.76 kB⬇
-
🌐 settings-utils.jsWeb, 31.08 kB⬇
-
🌐 share.jsWeb, 10.75 kB⬇
-
🌐 side-drawer.jsWeb, 9.37 kB⬇
-
🌐 speech-text.jsWeb, 6.60 kB⬇
-
🌐 swipe-navigation.jsWeb, 6.16 kB⬇
-
🌐 table-overlay.jsWeb, 8.10 kB⬇
-
🌐 theme-utils.jsWeb, 8.34 kB⬇
-
🌐 thinking-panel-base.jsWeb, 14.88 kB⬇
-
🌐 ui-sets.jsWeb, 1.00 kB⬇
-
🌐 version-overlay.jsWeb, 4.63 kB⬇
import SimpleBar from 'https://cdn.jsdelivr.net/npm/simplebar@6.2.7/+esm';
/**
* Returns the element that actually scrolls for a container: the SimpleBar
* scroll wrapper when the container is managed, the container itself
* otherwise (e.g. textareas and selects, or before initialization). Use for
* scroll math and scroll listeners.
* @param {HTMLElement} el - A scroll container, possibly SimpleBar managed.
* @returns {HTMLElement} The native scrolling element.
*/
export function scroller_of(el) {
return SimpleBar.instances.get(el)?.getScrollElement() ?? el;
}
/**
* Initializes a themed scrollbar on a container created at runtime; static
* containers declare data-simplebar in the markup instead.
* @param {HTMLElement} el - The container to manage.
* @returns {SimpleBar} The SimpleBar instance.
*/
export function init_simplebar(el) {
return new SimpleBar(el, { autoHide: false });
}
/**
* Returns the element that holds a container's content: SimpleBar moves
* children of a managed container into its content element, so content
* writes (innerHTML, append) must target it instead of the container.
* @param {HTMLElement} el - A container, possibly SimpleBar managed.
* @returns {HTMLElement} The element to write content into.
*/
export function content_of(el) {
return SimpleBar.instances.get(el)?.getContentElement() ?? el;
}
/**
* Mutates streamed content of a scroll container while keeping the view
* anchored to its bottom: the view follows the appended content only when it
* rested at the bottom before the mutation, so a user scroll-up breaks the
* anchor and scrolling back down re-engages it.
* @param {HTMLElement|null} scroller - The scrolling element.
* @param {Function} mutate - The content mutation (append) to run.
*/
export function append_following_bottom(scroller, mutate) {
const follow = !!scroller && scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 24;
mutate();
if (follow) scroller.scrollTop = scroller.scrollHeight;
}
// Containers that are display:none at init (dialogs, overlays) measure no
// overflow, and only content mutations make SimpleBar re-measure, so a newly
// opened one would stay unscrollable. Recalculate when a host first appears.
const io = new IntersectionObserver(entries => {
entries.forEach(en => {
if (en.isIntersecting) SimpleBar.instances.get(en.target)?.recalculate();
});
});
document.querySelectorAll('[data-simplebar]').forEach(el => io.observe(el));
// SimpleBar tracks are click-through (dragging and track clicks are handled
// through document-level pointer bounds checks), so wheel events over the
// visible scrollbar gutter would reach the overlay layers instead of the
// scroller and scroll nothing. Forward them to the scroller; thumb dragging
// and track clicks are pointer events and keep working.
document.addEventListener('wheel', (e) => {
if (!(e.target instanceof Element) || !e.target.closest('.simplebar-track')) return;
const host = e.target.closest('[data-simplebar]');
const vp = host && scroller_of(host);
if (!vp || e.deltaMode !== 0) return;
vp.scrollBy({ left: e.deltaX, top: e.deltaY });
e.preventDefault();
}, { passive: false });
scrollbars.js
×
Type: Web, text/x-java
3.12 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File
Type: Web, text/x-java
3.12 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File