- ! function(t, e, i) {
- if (void 0 === t.csdn && (t.csdn = {}, t.csdn.fixedSidebar = {}), !jQuery) return !1;
- t.csdn.fixedSidebar = function(e) {
- function o() {
- if ("right" === r.direction) var e = r.mainBox.offset().left + r.mainBox.width() - i(t).scrollLeft() + parseInt(r.sidebarLeftMargin);
- else var e = r.mainBox.offset().left - r.sidebar.width() - i(t).scrollLeft() - parseInt(r.sidebarRightMargin);
- ! function() {
- var o = i(t).scrollTop();
- n + r.sidebar.height() <= i(t).height() ? o > n ? r.sidebar.css({
- position: r.position,
- top: parseInt(r.top) + "px",
- "z-index": parseInt(r.zIndex),
- left: e,
- width: s,
- bottom: "auto"
- }) : r.sidebar.removeAttr("style") : r.mainBox.height() > r.sidebar.height() ? r.targetBox.height() <= i(t).height() && r.targetBox.height() + n - o <= i(t).height() ? o > n ? r.sidebar.css({
- position: r.position,
- top: parseInt(r.top) + "px",
- "z-index": parseInt(r.zIndex),
- left: e,
- width: s,
- bottom: "auto"
- }) : r.sidebar.removeAttr("style") : r.targetBox.height() > i(t).height() && r.targetBox.height() - o + r.mainBox.offset().top <= i(t).height() ? r.sidebar.css({
- position: r.position,
- bottom: parseInt(r.bottom) + "px",
- "z-index": parseInt(r.zIndex),
- left: e,
- width: s,
- top: "auto"
- }) : r.sidebar.removeAttr("style") : r.sidebar.removeAttr("style"), a = !0
- }()
- }
- var r = {
- targetBox: i(".persion_article"),
- mainBox: i("main"),
- sidebar: i("aside"),
- direction: "right",
- position: "fixed",
- top: 0,
- bottom: 0,
- zIndex: 99,
- sidebarRightMargin: 8,
- sidebarLeftMargin: 15
- };
- e && i.extend(r, e);
- var s = r.sidebar.width(),
- n = r.targetBox.offset().top,
- a = !0;
- o(), i(t).on("scroll", function() {
- a && t.csdn.fixedSidebar.stopListener && (setTimeout(o, 100), a = !1)
- }), i(t).on("resize", function() {
- o()
- })
- }, t.csdn.fixedSidebar.version = "1.1.7", t.csdn.fixedSidebar.stopListener = !0
- }(window, document, jQuery);
Raw Paste