Twitter feed 自动滚动

问题描述 投票:0回答:2

我的页面上有一个嵌入的 Twitter feed,用户可以向下滚动,但我希望它自动滚动。我想它可以添加到代码中,但不知道从哪里开始。请帮忙..

 <TwitterBox>
                    <Timeline
                        renderError={(_err) => <p>Could not load Twitter</p>}
                        dataSource={{
                            sourceType: 'profile',
                            screenName: 'vehicle',
                            width: "100%",
                        }}
                        options={{
                            height: '700',
                        }}


                    />
                </TwitterBox>
twitter autoscroll
2个回答
0
投票

我也许可以回答你的问题。另一个人制作了此代码,因此功劳将归于该人。这是您可能想尝试的代码。

scroll=window.setInterval(function(){window.scrollTo(0,document.body.scrollHeight);},1000);

使用说明

打开个人资料。您想要在浏览器中向下滚动到末尾。然后打开 _inspect element+ 模式(在 Chrome 浏览器中,点击 ctrl+shift+i 进入检查模式),然后单击 console 选项卡并粘贴此代码并按 Enter:

scroll=window.setInterval(function(){window.scrollTo(0,document.body.scrollHeight);},1000);

按下回车键后,您将在发布的代码行下方看到一个唯一的数字。它可以是 139、43、123 或任何数字。一旦到达配置文件末尾,我们将使用此数字停止滚动,因为即使您到达最后一篇文章,上述代码也会继续执行。

要停止向下滚动,只需将以下代码复制粘贴到控制台中并按 Enter 键即可。请务必将此处的号码替换为您第一次按 Enter 键时在控制台中获得的号码。

clearInterval(your number here);

示例:

clearInterval(3085);

enter image description here


0
投票

虽然该线程中的其他答案对我有很大帮助,但我发现最好使用scrollBy方法,特别是使用选项,因为它可以让您调整滚动的行为。

scroll=window.setInterval(function(){window.scrollBy({
top: 100,
left: 0,
behavior: "smooth",});},1000);

© www.soinside.com 2019 - 2024. All rights reserved.