单侧区域滑动效果
Posted mudeng007
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单侧区域滑动效果相关的知识,希望对你有一定的参考价值。
http://www.gamersky.com/news/201706/920789.shtml
function HomeScroll(n, t) { function u() { var y = $(window).scrollLeft(), c = $(window).scrollTop(), w = $(document).height(), u = $(window).height(), o = i.height(), s = r.height(), l = o > s ? e : f, a = o > s ? r : i, b = o > s ? i.offset().left + i.outerWidth(!0) - y : r.offset().left - i.outerWidth(!0) - y, h = o > s ? s : o, v = o > s ? o : s, p = parseInt(v - u) - parseInt(h - u); $(n + "," + t).removeAttr("style"); u > w || h > v || l > c || h - u + l >= c ? a.removeAttr("style") : u > h && c - l >= p || h > u && c - l >= v - u ? a.attr("style", "margin-top:" + p + "px;") : a.attr("style", "_margin-top:" + (c - l) + "px;position:fixed;left:" + b + "px;" + (u > h ? "top" : "bottom") + ":0;") } if (!navigator.userAgent.match(/(iPhone|iPad|iPod|android|ios)/i) && $(n).length > 0 && $(t).length > 0) { var i = $(n), r = $(t), f = i.offset().top, e = r.offset().top; $(window).resize(u).scroll(u).trigger("resize") } } function HomeScrollL(n, t) { if (!navigator.userAgent.match(/(iPhone|iPad|iPod|Android|ios)/i) && $(n).length > 0 && $(t).length > 0) { var i = $(n), u = $(t), r = i.offset().top; function f() { var s = $(window).scrollLeft(), f = $(window).scrollTop(), h = $(document).height(), n = $(window).height(), t = i.height(), e = u.height(), c = u.offset().left - i.outerWidth(!0) - s, o = parseInt(e - n) - parseInt(t - n); h < n || t > e || f < r || f <= t - n + r ? i.removeAttr("style") : n > t && f - r >= o || n < t && f - r >= e - n ? i.attr("style", "margin-top:" + o + "px;") : i.attr("style", "_margin-top:" + (f - r) + "px;position:fixed;left:" + c + "px;" + (n > t ? "top" : "bottom") + ":0;") } $(window).resize(f).scroll(f).trigger("resize") } } function HomeScrollR(n, t) { if (!navigator.userAgent.match(/(iPhone|iPad|iPod|Android|ios)/i) && $(n).length > 0 && $(t).length > 0) { var u = $(n), i = $(t), r = i.offset().top; function f() { var s = $(window).scrollLeft(), f = $(window).scrollTop(), h = $(document).height(), n = $(window).height(), e = u.height(), t = i.height(), c = u.offset().left + u.outerWidth(!0) - s, o = parseInt(e - n) - parseInt(t - n); h < n || t > e || f < r || f <= t - n + r ? i.removeAttr("style") : n > t && f - r >= o || n < t && f - r >= e - n ? i.attr("style", "margin-top:" + o + "px;") : i.attr("style", "_margin-top:" + (f - r) + "px;position:fixed;left:" + c + "px;" + (n > t ? "top" : "bottom") + ":0;") } $(window).resize(f).scroll(f).trigger("resize") } }
HomeScroll(".Mid1_L,.Mid2_L", ".Mid1_R,.Mid2_R");
以上是关于单侧区域滑动效果的主要内容,如果未能解决你的问题,请参考以下文章