A Simple Example of Moving Hoizontal Scroll Bar To Specific Location

A Simple Example of Moving Hoizontal Scroll Bar To Specific Location

chboccachbocca Posts: 53Questions: 10Answers: 0

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: 54,914Questions: 1Answers: 8,608 Site admin

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

    Allan

  • macmicromacmicro Posts: 14Questions: 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: 53Questions: 10Answers: 0

    Nice. Thank you!

  • macmicromacmicro Posts: 14Questions: 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: 53Questions: 10Answers: 0

    Love it!

Sign In or Register to comment.