码迷,mamicode.com
首页 > 其他好文 > 详细

单侧区域滑动效果

时间:2017-08-15 15:10:21      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:width   android   ipo   var   new   idt   pre   pos   class   

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

单侧区域滑动效果

标签:width   android   ipo   var   new   idt   pre   pos   class   

原文地址:http://www.cnblogs.com/mudeng-007/p/7364862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!