Ver Fonte

really fix scrolling to top of thread

Mike L há 3 anos atrás
pai
commit
c28618f2a0
2 ficheiros alterados com 3 adições e 1 exclusões
  1. 1 0
      dist/webshot.js
  2. 2 1
      src/webshot.ts

+ 1 - 0
dist/webshot.js

@@ -123,6 +123,7 @@ class Webshot extends CallableInstance {
                                     continue;
                                 return document.documentElement.scrollTop = window.scrollY + div.getBoundingClientRect().top;
                             }
+                            document.documentElement.scrollTop = 0;
                         });
                     })
                         .then(() => page.evaluate(() => {

+ 2 - 1
src/webshot.ts

@@ -138,7 +138,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
               logger.warn(`navigation timed out at ${getTimerTime()} seconds`);
               return null;
             })
-            // scroll to last tweet by owner in thread, if any, or top   of thread
+            // scroll to last tweet by owner in thread, if any, or top of thread
             .then((handle: puppeteer.ElementHandle<HTMLDivElement>) => {
               if (handle === null) throw new puppeteer.errors.TimeoutError();
               return handle.evaluate(div => {
@@ -150,6 +150,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
                   if (getProfileUrl() !== ownerProfileUrl) continue;
                   return document.documentElement.scrollTop = window.scrollY + div.getBoundingClientRect().top;
                 }
+                document.documentElement.scrollTop = 0;
               });
             })
             .then(() => page.evaluate(() => {