import {gsap} from "gsap";
import Draggable from "gsap/Draggable";
import { InertiaPlugin } from "./libs/gsap/InertiaPlugin";
import { ScrollToPlugin } from "./libs/gsap/ScrollToPlugin";
gsap.registerPlugin(Draggable)
gsap.registerPlugin(InertiaPlugin);
gsap.registerPlugin(ScrollToPlugin);
Draggable.create(scrollContainer, {
type: 'scrollTop',
inertia: true,
});这个简单的例子对桌面浏览器的垂直滚动/抛出效果很好。
当弹回顶部时,惯性插件会使内容过度滚动并反弹到起点。这很好。
然而,当仅仅拖拽时,就不会出现过度滚动。就像在iPad上一样。是否有可能在拖曳时使拖曳的超调/超滚动,并在拖曳结束时反弹?
编辑:下面是用示例编写的代码:
https://codepen.io/Agint/pen/LYZMyYR
(我找不到最新的gsap InertiaPlugin的cdn版本,所以这个版本是旧版本的。无论版本如何,其行为和问题都是完全相同的。在本地,我有最新的gsap版本,其中包含greensock的InertiaPlugin文件。)
发布于 2020-11-12 15:52:57
这正是edgeResistance的作用所在:
Draggable.create("#scrollContainer", {
type: "scrollTop",
inertia: true,
edgeResistance: 0.9
});https://stackoverflow.com/questions/64749230
复制相似问题