滚动元素的交叉溶解过渡
Cross-dissolve transition for scrolled elements
我正在创建一个长单页网站,并使用ScrollMagicJS v1.3.0来触发事件并使某些元素具有粘性。我想在向下滚动页面时创建各种其他过渡效果。
这是一个复制我网站的水平滚动的jsfiddle。
scrollControl = new ScrollMagic({
vertical: false,
});
var myScrollScene = new ScrollScene({
triggerHook: 0,
offset: 0,
triggerElement: '#shot-0-1',
duration: '100vw',
pushFollowers: true
})
.setPin('#shot-0-1')
.addTo(scrollControl);
例如,我想在页面之间创建淡入淡出到黑色、耀斑到白色和交叉溶解过渡。
我了解HTML5过渡的一些基本原则,如何使一个图像溶解到另一个图像中,但是我无法找到使用ScrollMagic滚动的聪明方法。
我考虑过的事情:下一页在当前页面下滑动,然后使用 ScrollMagic 触发器从 1.0 不透明度过渡到 0
?但是如何以一种非黑客的方式做到这一点,并与ScrollMagic的框架保持一致呢?
这在ScrollMagic的问题部分已经问过和回答了:https://github.com/janpaepke/ScrollMagic/issues/269
这是一份副本:
一个常见的误解是您需要使用ScrollMagic引脚功能执行所有操作。如果内容无论如何都没有在滚动流中移动(它保持在原位并淡出或移动到侧面或侧面),您可以从一开始就将其设置为"固定"。这样可以节省大量工作和混乱。
使用ScrollMagic的固定功能的唯一原因是元素有时应该使用DOM自然滚动,有时不应该。
因此,如果您有适当的元素并且应该被其他元素替换,请始终修复它们。像这样: https://jsfiddle.net/janpaepke/6kyd6ss0/1/
如果确实是这种情况,您应该使用ScrollMagic的固定方法,然后在您固定的包装器中执行动画。像这样:https://jsfiddle.net/janpaepke/6kyd6ss0/3/
确定的解决方案。
scrollControl = new ScrollMagic({
vertical: false,
});
vw = $(window).width();
console.log("width:" + vw + "px");
// pin frame 2
var myScrollScene = new ScrollScene({
triggerHook: 0,
triggerElement: '#shot-2',
// This pin is considerably longer than average
offset: 0,
// duration = stickyLength + disolve_duration
duration: 1.5 * vw + 'px'
})
.setPin('#content-2', {
pushFollowers: false
})
.addTo(scrollControl)
.addIndicators({
zindex: 100,
suffix: 'pin2'
});
// move frame 3 up early and pin it
var myScrollScene = new ScrollScene({
triggerHook: 0,
triggerElement: '#shot-2',
offset: 0,
// duartion = 1.5, but why?
duration: 1.5 * vw + 'px'
// the faux pin doesn't actually expand the container the way SM does
// so the results are a little strange
})
.on("start end", function (e) {
$('#content-3').css({left: 0, position:'fixed'});
})
.on("enter leave", function (e) {
$('#content-3').css({left: 0, position:'relative'});
})
.addTo(scrollControl)
.addIndicators({
zindex: 100,
suffix: 'pin3faux'
});
var dissolve = TweenMax.to('#content-2', 1, {
autoAlpha: 0
});
// dissolve frame 2 to frame 3
var myScrollScene = new ScrollScene({
triggerHook: 0,
// Note that though we are fading frame 2, we are
// using the arrival of frame 3 the trigger
triggerElement: '#shot-2',
// The sets the rapidity of the dissolve
// offset = stickyLength
offset: 0.33 * vw + 'px',
// The sets the rapidity of the dissolve
duration: 1 * vw + 'px'
})
.setTween(dissolve)
.addTo(scrollControl)
.addIndicators({
zindex: 100,
suffix: 'dissolve'
});
我使用了一个 pushFollowers:假在引脚和 z 索引上滑动下一帧(也固定)在第一帧后面。然后补间溶解到第二帧中。结果是一个不错的电影溶解功能,持续时间可调。
希望对其他人有用。
https://jsfiddle.net/wmodes/b4gdxeLn/
- 指示禁用元素滚动行为并改为滚动页面
- 在某个点停止固定元素滚动
- jQuery 航点在元素滚动到视图中时添加类
- 到达(窗口)上的中间元素.滚动
- 当元素滚动出屏幕时更改元素位置
- jQuery-将元素滚动到屏幕中间,而不是使用锚链接滚动到顶部
- 我想为一个元素添加一个事件监听器,当相应的元素滚动到视图中时,该监听器就会被激发
- 将元素滚动到页面底部的视图中
- fadeIn元素滚动
- 当光标到达底部时,有没有办法防止contentEditable元素滚动
- 固定元素滚动到Div
- 如何平滑地防止固定元素滚动经过指定元素
- 将所有HTML元素滚动到视图中
- 如果浏览器窗口高度为X,并且元素滚动到其中的X点,则合并条件
- 使用isroll4将最后一个元素滚动到第一个元素的开始位置
- 如何显示单独的锂元素滚动基于窗口的高度
- 根据所单击的元素滚动到页面上的相同位置
- 元素滚动的同时滚动另一个
- 修改jQuery.ScrollTo插件将元素滚动到页面中心(垂直/水平)或尽可能靠近中心
- 我如何检测一个元素滚动到视窗