Skip to content

Instantly share code, notes, and snippets.

/.js Secret

Created September 4, 2015 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8f77b4c43aef114a15b7 to your computer and use it in GitHub Desktop.
Save anonymous/8f77b4c43aef114a15b7 to your computer and use it in GitHub Desktop.
if($(".index").scrollTop() + $('.index').height() > $('.index').height() + $('.index').height() - 100) {
alert("near bottom!");
}
----
if($('.index').height() > $(document).height() - 100) {
alert("near bottom!");
}
----
var docHeight = $(document).height(),
scrollTop = $(document).scrollTop(),
windowHeight = $(window).height();
if (docHeight - (scrollTop + windowHeight) <= 100) {
alert(docHeight - (scrollTop + windowHeight));
}
----
var scrollPos = $('#viewable-div').height() - $('#scrolling-content').height();
if ($("#scrolling-content").scrollTop() > (scrollPos - 100)) {
alert("here")
}
----
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
alert("hello")
}
----
Maybe relevant:
CSS included
@media only screen and (min-device-width: 481px) {
body {
-moz-transform: scale(0.75, 0.75); /* Moz-browsers */
zoom: 0.75; /* Other non-webkit browsers */
zoom: 75%; /* Webkit browsers */
}
}
This is a rails app and I also have this in my application.html.erb file
<script>
(function(){
$(window).scroll(function() {
if($(this).scrollTop() > 50) {
$('.navbar').addClass('opaque')
} else {
$('.navbar').removeClass('opaque');
}
if($(this).scrollTop() > 285) {
$('.nav_submit').removeClass('hide_nav_submit');
} else {
$('.nav_submit').addClass('hide_nav_submit');
}
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment