A Simple Example of Moving Hoizontal Scroll Bar To Specific Location

A Simple Example of Moving Hoizontal Scroll Bar To Specific Location

chboccachbocca Posts: 86Questions: 13Answers: 1

Building on Allan's guidance in "How do I scroll to a specific column," thought I'd share a simple example here.

Click on button to see scrollx position or another to move horizontal scroll bar.

Replies

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    Nice one! Thanks for sharing this working solution with us :).

    Allan

  • macmicromacmicro Posts: 15Questions: 0Answers: 0

    Hello,
    I improved your code by doing this and creating two buttons with the code below.

                {
                text: 'Scroll left',
                className: 'scroll',
                action: function ( e, dt, node, config ) {
                    var leftPos = $('div.dataTables_scrollBody').scrollLeft();
                    $("div.dataTables_scrollBody").animate({scrollLeft: leftPos - 30}, 100);
                    }
                },
                {
                text: 'Scroll right',
                className: 'scroll',
                action: function ( e, dt, node, config ) {
                  var leftPos = $('div.dataTables_scrollBody').scrollLeft();
                  $("div.dataTables_scrollBody").animate({scrollLeft: leftPos + 30}, 100);
                    }
                },
    

    cordially

  • chboccachbocca Posts: 86Questions: 13Answers: 1

    Nice. Thank you!

  • macmicromacmicro Posts: 15Questions: 0Answers: 0

    Hello,
    If you are interested, I made a new version by customizing the scrollbars.
    live.datatables.net/jajeciti/1/edit
    Rey

  • chboccachbocca Posts: 86Questions: 13Answers: 1

    Love it!

This discussion has been closed.