MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / box_scroll_to

Function box_scroll_to

webiojs/src/utils.ts:104–116  ·  view source on GitHub ↗
(target: JQuery, container: JQuery, position = 'top', complete?: (this: HTMLElement) => void, offset = 0)

Source from the content-addressed store, hash-verified

102
103// container 为带有滚动条的元素
104export function box_scroll_to(target: JQuery, container: JQuery, position = 'top', complete?: (this: HTMLElement) => void, offset = 0) {
105 let scrollTopOffset = null;
106 if (position === 'top')
107 scrollTopOffset = target[0].getBoundingClientRect().top - container[0].getBoundingClientRect().top;
108 else if (position === 'middle')
109 scrollTopOffset = target[0].getBoundingClientRect().top - container[0].getBoundingClientRect().top - container.height() * 0.5 + target.height() * 0.5;
110 else if (position === 'bottom')
111 scrollTopOffset = target[0].getBoundingClientRect().bottom - container[0].getBoundingClientRect().bottom;
112
113 let speed = Math.min(Math.abs(scrollTopOffset + offset), 500) + 100;
114 if (scrollTopOffset !== null)
115 container.stop().animate({scrollTop: container.scrollTop() + scrollTopOffset + offset}, speed, complete);
116}
117
118
119export function randomid(length: number) {

Callers

nothing calls this directly

Calls 1

stopMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…