Created
November 18, 2014 07:31
-
-
Save alanerzhao/ec30398f0a644575b750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seajs.use(['jquery'],function($) { | |
//hover | |
var hover = (function () { | |
function init () { | |
var _item = $(".J_list"); | |
_item.on("mouseenter","dl",function(){ | |
var _self = $(this); | |
_self.addClass("J_hover").siblings().removeClass("J_hover"); | |
}); | |
} | |
return { | |
init: init | |
} | |
})() | |
//fixedSlidebar | |
var fixedSlidebar = (function () { | |
if(!window.XMLHttpRequest) { | |
return false; | |
} | |
function init () { | |
var _fixed = $(".J_fixed"), | |
_w = $(window), | |
fixedTop = _fixed.offset().top; | |
isScroll = false; | |
_w.bind("scroll",function () { | |
var _self = $(this), | |
scrollTop = _self.scrollTop(), | |
top = _fixed.offset().top; | |
// console.log(scrollTop,$(".feed-box-content").height() - $(".feed-footer").height()) | |
if(scrollTop > top) { | |
_fixed.css({ | |
"position": "fixed", | |
"top": 0 | |
}) | |
} else if(scrollTop <= fixedTop) { | |
isScroll = true; | |
_fixed.css({ | |
"position": "static", | |
}) | |
} | |
console.log(scrollTop,top,fixedTop); | |
}) | |
} | |
return { | |
init: init | |
} | |
})() | |
$(function() { | |
var fixedObj = $(".feed-box-content-sidebar"); | |
hover.init(); | |
fixedObj.stick_in_parent() | |
//fixedSlidebar.init(); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment