$(document).ready(function(){ $("#mYoutube .youtube_box .youtube_list a").click(function(){ $("#mYoutube .youtube_box .youtube iframe").remove(); $("#mYoutube .youtube_box .youtube").append($(this).html()); return false; }) $(".sProduct_case1 .tab_box li").hover(function(){ $(".sProduct_case1 .tab_box li").removeClass("on") $(this).addClass("on") $(".sProduct_case1 .content_box > div").removeClass("on") $(".sProduct_case1 .content_box > div:eq("+ $(this).index() +")").addClass("on") }) }) var scroll = function(){ var $nav = null, $cnt = null, moveCnt = null, moveIndex = 0, moveCntTop = 0, winH = 0, time = false; // 새로 만든 변수 $(document).ready(function(){ init(); initEvent(); $("#footer .go_top").click(function(){ moveIndex = 0; }) if (moveIndex == 0){ $(".content_quick").addClass("hide") } else { $(".content_quick").removeClass("hide") } }); var init = function(){ $cnt = $(".content"); $nav = $(".content_quick a"); }; var initEvent = function(){ $("html ,body").scrollTop(0); if ($(window).width() > 1024){ winResize(); } $(window).resize(function(){ if ($(window).width() > 1024){ winResize(); } }); $nav.on("click", function(){ moveIndex = $(this).parent("li").index(); moving(moveIndex); return false; }); $cnt.on("mousewheel", function(e){ if(time === false){ // time 변수가 펄스일때만 휠 이벤트 실행 wheel(e); } }); }; var winResize = function(){ winH = $(window).height(); $cnt.children("div").height(winH); $("html ,body").scrollTop(moveIndex.scrollTop); }; var wheel = function(e){ if ($(window).width() > 1024){ if(e.originalEvent.wheelDelta < 0){ if(moveIndex < 7){ moveIndex += 1; moving(moveIndex); }; }else{ if(moveIndex > 0){ moveIndex -= 1; moving(moveIndex); }; }; } }; var moving = function(index){ time = true // 휠 이벤트가 실행 동시에 true로 변경 moveCnt = $cnt.children("div").eq(index); moveCntTop = moveCnt.offset().top; $("html ,body").stop().animate({ scrollTop: moveCntTop }, 1000, function(){ time = false; // 휠 이벤트가 끝나면 false로 변경 }); if (index == 0){ $(".content_quick").addClass("hide") } else { $(".content_quick").removeClass("hide") } if (index == 2 || index == 6){ $(".content_quick").addClass("white") } else { $(".content_quick").removeClass("white") } $nav.parent("li").eq(index).addClass("on").siblings().removeClass("on"); }; }; scroll();