我在寻找一个应该在滚动上垂直改变滑块的滑块。滚动上的垂直滑块
这是refrence网址:https://www.uber.com/的移动滑块
请帮助我,我试图做到这一点since7,8小时。 这是我正在尝试使用的代码。
$(document).ready(function() {
// var totalheight=$(window).height();
// $('.carosel-section').css('height',totalheight);
//Set each section's height equals to the window height
//$('.moveable').height($(window).height());
$('.moveable').first().addClass('active');
$('.carousel-wrap').on('mousewheel DOMMouseScroll', function (e) {
e.preventDefault();//prevent the default mousewheel scrolling
var active = $('.moveable.active');
var delta = e.originalEvent.detail < 0 || e.originalEvent.wheelDelta > 0 ? 1 : -1;
if (delta < 0) {
//mousewheel down handler
next = active.next();
if (next.length) {
var timer = setTimeout(function() {
$('body, html').animate({
scrollTop: next.offset().top
}, 'fast');
// move the indicator 'active' class
next.addClass('active')
.siblings().removeClass('active');
clearTimeout(timer);
}, 100);
}
} else {
prev = active.prev();
if (prev.length) {
var timer = setTimeout(function() {
$('body, html').animate({
scrollTop: prev.offset().top
}, 'slow');
prev.addClass('active')
.siblings().removeClass('active');
clearTimeout(timer);
}, 800);
}
}
});
});
你可以分享可执行的演示/片段或[JSFiddle](https://jsfiddle.net/)吗?我们如何执行提供的代码? – Rayon
其实我只是试了一下代码。它不起作用。我添加了内联滚动到幻灯片,然后尝试实现部分内的一个页面滚动效果。 – shalini
你想让整个页面能够垂直滑动吗?或者仅仅是Uber的部分? – Roy