1. 程式人生 > >單側區域滑動效果

單側區域滑動效果

use () attr user div trigge androi news resize

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");

單側區域滑動效果