每當我將translate()CSS 函數添加到元素將離開視口的react-spring useTransition鉤子from或leave屬性時,我都會得到一個垂直/水平滾動條。const transitions = useTransition(show, null, { from: { opacity: 0, transform: "translate3d(500px,0px,0px) scale(1)" }, enter: { opacity: 1, transform: "translate3d(0px,0px,0px) scale(1)" }, leave: { opacity: 0, transform: "translate3d(0px,-500px,0px) scale(1)" }, config: { duration: 3000 }});我知道這是意料之中的,一般的解決方案是添加overflow: hidden到body.但是我不確定在動畫發(fā)生時如何執(zhí)行此操作?因為我不想一直添加overflow: hidden,body因為我確實需要訪問某些頁面中的滾動條,而不是在動畫啟動時?這是一個CodeSandbox供您自己嘗試
防止?jié)L動條出現在變換上:使用 React-Spring 進行翻譯
藍山帝景
2022-01-20 20:41:30