Skip to content

Commit

Permalink
fix scrolling problem
Browse files Browse the repository at this point in the history
  • Loading branch information
LawyZheng committed May 9, 2024
1 parent ebfc1a6 commit f4e1155
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions skyvern/webeye/scraper/domUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ function removeBoundingBoxes() {

function scrollToTop(draw_boxes) {
removeBoundingBoxes();
window.scrollTo(0, 0);
window.scrollTo({ left: 0, top: 0, behavior: "instant" });
scrollDownAndUp();
if (draw_boxes) {
var elementsAndResultArray = buildTreeFromBody();
Expand All @@ -1153,7 +1153,11 @@ function scrollToNextPage(draw_boxes) {
// remove bounding boxes, scroll to next page with 200px overlap, then draw bounding boxes again
// return true if there is a next page, false otherwise
removeBoundingBoxes();
window.scrollBy(0, window.innerHeight - 200);
window.scrollBy({
left: 0,
top: window.innerHeight - 200,
behavior: "instant",
});
scrollUpAndDown();
if (draw_boxes) {
var elementsAndResultArray = buildTreeFromBody();
Expand All @@ -1166,18 +1170,18 @@ function scrollUpAndDown() {
// remove select2-drop-above class to prevent dropdown from being rendered on top of the box
// then scroll up by 1 and scroll down by 1
removeSelect2DropAbove();
window.scrollBy(0, -1);
window.scrollBy({ left: 0, top: -1, behavior: "instant" });
removeSelect2DropAbove();
window.scrollBy(0, 1);
window.scrollBy({ left: 0, top: 1, behavior: "instant" });
}

function scrollDownAndUp() {
// remove select2-drop-above class to prevent dropdown from being rendered on top of the box
// then scroll up by 1 and scroll down by 1
removeSelect2DropAbove();
window.scrollBy(0, 1);
window.scrollBy({ left: 0, top: 1, behavior: "instant" });
removeSelect2DropAbove();
window.scrollBy(0, -1);
window.scrollBy({ left: 0, top: -1, behavior: "instant" });
}

function removeSelect2DropAbove() {
Expand Down

0 comments on commit f4e1155

Please sign in to comment.