Commit ea70cf5a authored by 杨奕's avatar 杨奕 Committed by GitHub

Utils: scroll-into-view should consider target element's offset parents (#11058)

parent 71a66ae2
...@@ -36,7 +36,7 @@ if [ "$TRAVIS_TAG" ]; then ...@@ -36,7 +36,7 @@ if [ "$TRAVIS_TAG" ]; then
# build site # build site
npm run deploy:build npm run deploy:build
cd temp_web 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 # build sub folder
echo $TRAVIS_TAG echo $TRAVIS_TAG
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
mkdir temp_web mkdir temp_web
npm run deploy:build npm run deploy:build
cd temp_web 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 # build sub folder
SUB_FOLDER='2.3' SUB_FOLDER='2.3'
......
...@@ -8,8 +8,14 @@ export default function scrollIntoView(container, selected) { ...@@ -8,8 +8,14 @@ export default function scrollIntoView(container, selected) {
return; return;
} }
const top = selected.offsetTop; const offsetParents = [];
const bottom = selected.offsetTop + selected.offsetHeight; 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 viewRectTop = container.scrollTop;
const viewRectBottom = viewRectTop + container.clientHeight; const viewRectBottom = viewRectTop + container.clientHeight;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment