-
-
Save jimitit/26dd03c8ed0571f993ea to your computer and use it in GitHub Desktop.
Sticky column on horizontal scroll
This file contains 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 lastScrollLeft = 0; | |
$(window).scroll(function() { | |
var documentScrollLeft = $(document).scrollLeft(); | |
if (lastScrollLeft != documentScrollLeft) { | |
//console.log('scroll x' + documentScrollLeft); | |
//For first column check below line: *:nth-child(1) | |
$('#tbl_newdashboard > tbody').find("tr > *:nth-child(1)").css({ | |
'position' : 'relative', | |
'left': documentScrollLeft + 'px', | |
'background-color': 'white', | |
'display': 'table-cell', | |
'background-clip': 'padding-box' | |
}); | |
lastScrollLeft = documentScrollLeft; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment