skrollr
skrollr copied to clipboard
Simple Add/Remove element classes
Hi, Sorry for my poor knowledge in Skrollr, I am just getting started with it and in totally elementary phase, also, I am a designer, so I also lack sophisticated skills in JS.
My issue is, in my scenario, I simply need to add/remove classes as per the position of the element. So I used the data--100-top="@class: myclass" data-top-bottom="@class:"
and it removes all other classes already present in the element. Is there any workaround to simply add/remove classes?
Or, is there anyway to attach events when the element enters/leaves the defined position , like data-event-entry="elemententered" data-event-leave="elementleaved"
so that we can use
jQuery(document).ready(function($) {
// Initiate Skrollr
var s = skrollr.init({
render: function(data) {
//Debugging - Log the current scroll position.
//console.log(data.curTop);
}
});
$('#elemid').on( 'elemententered', function() {
$(this).addClass('myclass');
}).on( 'elementleaved', function() {
$(this).removeClass('myclass');
});
});
Thanks.