mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-02 04:08:10 +08:00
Utils: scroll-into-view should consider target element's offset parents (#11058)
This commit is contained in:
parent
71a66ae21d
commit
ea70cf5a01
@ -36,7 +36,7 @@ if [ "$TRAVIS_TAG" ]; then
|
||||
# build site
|
||||
npm run deploy:build
|
||||
cd temp_web
|
||||
git clone -b gh-pages https://$ROT_TOKEN@github.com/ElemeFE/element.git && cd element
|
||||
git clone --depth 1 -b gh-pages --single-branch https://$ROT_TOKEN@github.com/ElemeFE/element.git && cd element
|
||||
# build sub folder
|
||||
echo $TRAVIS_TAG
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
mkdir temp_web
|
||||
npm run deploy:build
|
||||
cd temp_web
|
||||
git clone -b gh-pages https://github.com/ElemeFE/element.git && cd element
|
||||
git clone --depth 1 -b gh-pages --single-branch https://github.com/ElemeFE/element.git && cd element
|
||||
|
||||
# build sub folder
|
||||
SUB_FOLDER='2.3'
|
||||
|
@ -8,8 +8,14 @@ export default function scrollIntoView(container, selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
const top = selected.offsetTop;
|
||||
const bottom = selected.offsetTop + selected.offsetHeight;
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user