-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Deactivate/block jquery.sticky.js on mobile devices #265
Comments
@giuliamontes I could handle sticky elements on mobile considering screen $(window).resize(function() {
var windowWidth = $(window).width();
if (windowWidth > 768) {
stick();
}
else {
unstick();
}
});
function stick() {
$("#sticker").sticky({
topSpacing: 10,
responsiveWidth: true
});
}
function unstick() {
$('#sticker').unstick();
} |
@nersoh Hi, thanks. I tried but it doesn't work :( maybe my code is wrong |
@nersoh Your code works great for me. One important thing to note @giuliamontes is you still need to make sure and call the sticky function outside of window.resize. Otherwise you must resize the window before any of that code will run. It would be nice if there was some build in support for this. |
I'm using this on Wordpress as below, but it only works after I hit refresh. `jQuery(document).ready(function(){
});` Not sure why this isn't firing from the beginning. P.S. Not a programmer. |
Another option could be using
in your css. This will override the inline |
I've a problem. I have to deactivate or block the fixed position of a sticky element on mobile devices to avoid the overlap of the fixed sidebar. The code is this:
Suggestions? Thanks
The text was updated successfully, but these errors were encountered: