Last active
August 29, 2015 14:21
-
-
Save sundaycrafts/d5b475c0b9ffac4f4099 to your computer and use it in GitHub Desktop.
scrollableElement.js
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
// http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links | |
function scrollableElement(els) { | |
for(var i = 0, len = arguments.length; i < len; i++) { | |
var el = arguments[i], | |
$scrollElement = $(el); | |
if($scrollElement.scrollTop() > 0) { | |
return el; | |
} else { | |
$scrollElement.scrollTop(1); | |
var isScrollable = $scrollElement.scrollTop() > 0; | |
$scrollElement.scrollTop(0); | |
if(isScrollable) { | |
return el; | |
} | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment