Open mkaizumi opened 7 years ago
Wondering how to do this myself. Any thoughts?
@ao @mkaizumi Hi! In case you didn't figured it out, I managed to do it by doing something like this:
# When scrolling
$(window).scroll( () ->
# Get window position
# console.log $(window).scrollTop()
position = 123 # OR position = $("#myDiv").offset().top
if ($(window).scrollTop() >position )
$("#sticky").unstick()
else
$("#sticky").sticky()
)
You can have a look at this stackoverflow answer https://stackoverflow.com/questions/13522971/jquery-to-detect-scrolling-div-position
Hope it helps! :)
I tried to add it to my script but not working. Please check this.
@saruban I think you have to rewrite it in javascript (it's coffeescript here! :) )
Can you please help me to rewrite it on js. :)
On 1 Aug 2017 17:39, "Arpsara" notifications@github.com wrote:
@saruban https://github.com/saruban I think you have to rewrite it in javascript (it's coffeescript here! :) )
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/garand/sticky/issues/256#issuecomment-319352037, or mute the thread https://github.com/notifications/unsubscribe-auth/AJiowYed1fTUOej4b3wbtzfOlGP9wHRLks5sTxWSgaJpZM4NUms3 .
@saruban
$(window).scroll(function() {
var position;
position = 123;
if ($(window).scrollTop() > position) {
return $("#sticky").unstick();
} else {
return $("#sticky").sticky();
}
});
Thank you so much. Will Check and back to you. :)
On 1 Aug 2017 6:24 pm, "Andrew Odendaal" notifications@github.com wrote:
@saruban https://github.com/saruban
$(window).scroll(function() { var position; position = 123; if ($(window).scrollTop() > position) { return $("#sticky").unstick(); } else { return $("#sticky").sticky(); } });
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/garand/sticky/issues/256#issuecomment-319361493, or mute the thread https://github.com/notifications/unsubscribe-auth/AJiowR4hR8hCp4dVEK94VT4uFXFLHyDMks5sTx_wgaJpZM4NUms3 .
You don't need to unstick.
Proper way is to determine "bottomSpacing" value correctly based on the height of the footer that can be variable in some cases.
Just add dummy divs on the page with div(id="contentEnd") - where main page content ends and starts footer div(id="pageEnd") - at the end of the footer
And then initialize Sticky plugin
bottomSpacing = $("#pageEnd").offset().top - $("#contentEnd").offset().top
$('#sticky').sticky
topSpacing: 100
bottomSpacing: bottomSpacing
You can view more detail how to pause sticky when reach destination point - https://github.com/garand/sticky/issues/257#issuecomment-351935092
Another option that worked a little better in my situation
var footerBottomAdjust = $('#footer').height() + 50;
$('#sticky').sticky({
topSpacing: 200,
bottomSpacing: footerBottomAdjust
});
@jeremy-hawes tyvm!
I was thinking how to unstick when sticker just reach the footer, I don't want the sticker is overlapping or get behind it and just slide it away.. anyone know how to unstick the sticker before is reach footer? thanks