"Page on scroll" plugin

"Page on scroll" plugin

BLSullyBLSully Posts: 24Questions: 1Answers: 0
edited December 2012 in Plug-ins
Hey all,

I just wrote this little guy as I had a really long table that i figured would be a lot easier to scroll through.

Feel free to use and if you have any improvements (I literally wrote this 10 minutes ago and it works well enough for my use case), please feel free to leave them here and I'll update the original accordingly:

[code]
(function ($) {
$.fn.dataTableScroller = function () {
var dt;
//throw if we call this on something that isn't a dataTable. Won't have 'fnPageChange' method available
if (!('fnGetData' in this)) { throw "Initialized on something that isn't a DataTable"; }
//cache the dataTable so we don't have to look it up every time the event fires
dt = $(this).dataTable();

dt.on('mousewheel', function (ev) {
if (ev.originalEvent.wheelDelta) {
if (ev.originalEvent.wheelDelta < 1) {
dt.fnPageChange('next');
} else {
dt.fnPageChange('previous');
}
ev.preventDefault();
}
});
}
}(jQuery));
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That's great :-)

    Thanks very much for sharing this with us!

    Regards,
    Allan
This discussion has been closed.