Download Fore_End/cpcn2/node_modules/element-ui/src/utils/scroll-into-view.js from zxy0307/JavaWeb: direct link, hf CLI and curl.
- Browser
- Download file 824 Bytes
-
https://huggingface.co/zxy0307/JavaWeb/resolve/main/Fore_End/cpcn2/node_modules/element-ui/src/utils/scroll-into-view.js
- Command line
-
hf download hf://zxy0307/JavaWeb/Fore_End/cpcn2/node_modules/element-ui/src/utils/scroll-into-view.js
-
curl -L -o scroll-into-view.js https://huggingface.co/zxy0307/JavaWeb/resolve/main/Fore_End/cpcn2/node_modules/element-ui/src/utils/scroll-into-view.js
824 Bytes
| import Vue from 'vue'; | |
| export default function scrollIntoView(container, selected) { | |
| if (Vue.prototype.$isServer) return; | |
| if (!selected) { | |
| container.scrollTop = 0; | |
| return; | |
| } | |
| const offsetParents = []; | |
| let pointer = selected.offsetParent; | |
| while (pointer && container !== pointer && container.contains(pointer)) { | |
| offsetParents.push(pointer); | |
| pointer = pointer.offsetParent; | |
| } | |
| const top = selected.offsetTop + offsetParents.reduce((prev, curr) => (prev + curr.offsetTop), 0); | |
| const bottom = top + selected.offsetHeight; | |
| const viewRectTop = container.scrollTop; | |
| const viewRectBottom = viewRectTop + container.clientHeight; | |
| if (top < viewRectTop) { | |
| container.scrollTop = top; | |
| } else if (bottom > viewRectBottom) { | |
| container.scrollTop = bottom - container.clientHeight; | |
| } | |
| } | |