영카트 5.3기준 스크롤시 aside 고정시키기

qna 답변에 쓰고 아까워서 남겨봅니다.
#aside가 모니터높이보다 클수가있어서 fixed될때 스크롤생기게 해놨어요.
DEMO : http://spec.sekti.net/shop/list.php?ca_id=10

<style>
#wrapper.aside_fixed #aside{
position:fixed;
display: block;
z-index:9999;
top:0;
height: 100%;
overflow-y: auto;
}
#wrapper.aside_fixed #aside.reach-end{
position: absolute!important;
bottom: 0!important;
top: auto!important;
height: 100vh;
}
#wrapper.aside_fixed #container{
margin-left:235px;
}
</style>
<script>
$(document).ready(function () {

var $container = $("#container");
var $wrapper = $("#wrapper");
var $aside = $("#aside");
var container_top = $container.offset().top;
var $wrapper_bottom = $wrapper.offset().top+$wrapper.outerHeight();

(check_reach_end = function () {
var scroll_top = $(window).scrollTop();
var sticky_limit_top = $wrapper_bottom-$aside.outerHeight();


if(scroll_top>sticky_limit_top){
$aside.addClass('reach-end')

}else{
$aside.removeClass('reach-end')

}

if(scroll_top > container_top){
$wrapper.addClass('aside_fixed')
return false;
}

if(scroll_top < container_top){
$wrapper.removeClass('aside_fixed')
return false;
}
})();


$(window).scroll(function () {
check_reach_end();
});

})
</script>
|

댓글 1개

댓글을 작성하시려면 로그인이 필요합니다.

영카트5 팁자료실

+
제목 글쓴이 날짜 조회
6년 전 조회 4,195
6년 전 조회 4,539
6년 전 조회 3,983
6년 전 조회 3,537
6년 전 조회 2,606
6년 전 조회 5,139
6년 전 조회 3,234
6년 전 조회 6,431
6년 전 조회 3,132
6년 전 조회 3,212
6년 전 조회 3,041
6년 전 조회 3,238
6년 전 조회 2,950
6년 전 조회 2,168
6년 전 조회 3,227
6년 전 조회 2,777
6년 전 조회 3,613
6년 전 조회 4,730
6년 전 조회 9,588
6년 전 조회 4,228
6년 전 조회 4,089
6년 전 조회 4,671
6년 전 조회 4,319
6년 전 조회 5,262
6년 전 조회 5,901
6년 전 조회 3,297
7년 전 조회 3,001
7년 전 조회 4,773
7년 전 조회 4,387
7년 전 조회 3,737