//스크롤 왼쪽으로 이동
var moveLeft=0;
$(".top-menu").hover(
function(){
$("html,body").css({
"overflow-y":"hidden",
// "-ms-overflow-style":"none",
// "scrollbar-width":"none"
});
$("html::-webkit-scrollbar,body::-webkit-scrollbar").css({
display:"none"
})
$(".top-menu").on("mousewheel",function(e){
var wheelDelta=e.originalEvent.wheelDelta;
if(wheelDelta>0){
console.log("up");
moveLeft=-wheelDelta+$(this).scrollLeft();
// $(this).scrollLeft(-wheelDelta+$(this).scrollLeft());
}else{
console.log("down");
moveLeft=-wheelDelta+$(this).scrollLeft();
// $(this).scrollLeft(-wheelDelta+$(this).scrollLeft());
}
$(this).stop().animate({
scrollLeft:moveLeft
});
})
},
function(){
$("html,body").css({
overflow:"auto"
});
}
);
섹션마다 왼쪽으로 이동
$(function(){
var sWidth=$(".wrap").width();
var sLength=$(".section").length;
$(".section-wrap").css({
width:sWidth*sLength
});
$(".section").css({
width:sWidth,
float:"left"
});
var last=0;
var indexP
var moveLeft=0;
var sectionWidth=0;
function wheel(){
var winWidth=$(window).width();
$(".section").css({
width:winWidth
});
$(".section-wrap").css({
width:winWidth*sLength
});
$(".section").each(function(index){
$(this).on('DOMMouseScroll mousewheel', function(e){
if(e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
console.log("올렸어요");
if($(this).prev()!=undefined){
moveLeft=$(this).prev().offset().left;
indexP=index-1;
}
}else{
console.log("내렸어요")
if($(this).next()!=undefined){
moveLeft=$(this).next().offset().left;
indexP=index+1;
}
}
$("html,body").stop().animate({
scrollLeft:moveLeft
},500);
$(window).resize(function(){
var sectionWidth=$(window).width();
$("html,body").stop().animate({
scrollLeft:sectionWidth*indexP
},0);
});
});
});
}
wheel();
$(window).resize(function(){
wheel();
});
});
});