JSFiddle - React, Tailwind, and code Playground
by Christian Gambardella
HTML
<button id="add" type="button">add</button>
<button id="remove" type="button">remove</button>
<div id="articles">
</div>
CSS
#articles {
height: 2000px;
width: 100%;
background-color: #aaa;
}
JavaScript
var NiceBla = {
scrollHandler: function() {
console.log("scrolling");
},
add: function() {
$(document).bind('scroll', NiceBla.scrollHandler);
},
remove: function() {
$(document).unbind('scroll', NiceBla.scrollHandler);
}
};
$('#add').click(function() {
console.log('add');
NiceBla.add();
});
$('#remove').click(function() {
console.log('remove');
NiceBla.remove();
});