Created
June 9, 2015 00:12
-
-
Save skillmatic-co/f6b77984c27d0bde99c2 to your computer and use it in GitHub Desktop.
Scroll Sync
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
define("Network.scroll", ["jQuery", "Support.position-fixed", "Support.css-transform"], function(a, b, c) { | |
function d() { | |
k = j.outerHeight(), h.css({ | |
position: "static", | |
width: "" | |
}), h.css({ | |
width: function() { | |
return h[0].getBoundingClientRect().width | |
}, | |
left: h.offset().left, | |
top: k | |
}) | |
} | |
function e(b) { | |
b.preventDefault(); | |
var c = 0, | |
d = f.scrollTop() + k, | |
e = g.offset().top, | |
j = d - e, | |
l = g.outerHeight(), | |
m = i.outerHeight(), | |
n = l - m; | |
if (!(m >= l)) { | |
if (j > 0) { | |
h.css({ | |
position: "fixed" | |
}); | |
var o = Math.min(100, 100 / (l - (f.height() - a(".footer").outerHeight() - parseInt(a(".page").css("padding-bottom")) - k)) * j); | |
c = j - n * o / 100 | |
} else h.css({ | |
position: "static" | |
}); | |
h.css({ | |
"-webkit-transform": "translateY(-" + c + "px) translateZ(1px)", | |
"-moz-transform": "translateY(-" + c + "px) translateZ(1px)", | |
"-ms-transform": "translateY(-" + c + "px)", | |
"-o-transform": "translateY(-" + c + "px) translateZ(1px)", | |
transform: "translateY(-" + c + "px) translateZ(1px)" | |
}) | |
} | |
} | |
var f = a(window), | |
g = a(".network__news").first(), | |
h = a(".network__social").first(), | |
i = h.find(".wall"), | |
j = a(".header--bar"), | |
k = 0; | |
g.length && h.length && b && c && (d(), f.on("resize", function(a) { | |
d(a), e(a) | |
}), f.on("scroll", e)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment