简体   繁体   English

如何防止滚动更改弹出器位置?

[英]How prevent change popper placement with scroll?

I want to fix the popper element's position and not change the placement with later updates (without disabling the scroll listener).我想修复 popper 元素的 position 而不是通过以后的更新更改位置(不禁用滚动侦听器)。

The gif shows you my sticky popper, but I want it to be static. (don't change position on scroll): gif 向您展示了我的 sticky popper,但我希望它是 static。(不要在滚动条上更改 position):

在此处输入图像描述

Popper uses some modifiers that are not customizable, Instead, I use a new library whose name is Floating UI (the evolution of Popper 2). Popper 使用了一些不可自定义的修饰符,相反,我使用了一个名为Floating UI的新库(Popper 2 的演变)。

Floating UI extended modifiers to something new as middleware.浮动 UI将修饰符扩展到新的中间件。 One of them whose name is shift can be or not be in the middleware list to handle shifting popper elements in the exiting from viewport situation.其中一个名为shift的中间件可以在也可以不在中间件列表中,以处理从视口退出的情况下移动的 popper 元素。

You can find further information at Floating UI doc .您可以在Floating UI 文档中找到更多信息。

shift() moves the floating element along the specified axes in order to keep it in view. shift() 沿着指定的轴移动浮动元素以使其保持在视图中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM