Last active
August 29, 2015 14:19
-
-
Save Riveascore/5b82355ac983077f7823 to your computer and use it in GitHub Desktop.
Loading cube animation, wrote on paper first using shorthand, looks pretty funny when you quickly type it out
This file contains hidden or 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
var $lC = $loadingObject.find('.loading-cube'), | |
sT = $(window).scrollTop(), | |
eOT = $thisOffset.top, | |
eH = $this.height(), | |
wH = $(window).height(), | |
cH = 25, | |
nCP; | |
eVH; | |
if(sT > eOT) { | |
if(eOT + cH > sT + wH) { | |
eVH = wH; | |
} | |
else { | |
eVH = eOT + eH + sT; | |
} | |
nCP = sT + eVH / 2 - cH / 2; | |
} | |
else { | |
eVH = sT + wH - eOT; | |
nCP = eVH / 2 - cH / 2 | |
} | |
// Now, only change cube top when necessary | |
if(eH > eVH) { | |
$lC.offset({ top: nCP }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment