Results 1 to 5 of 5

Thread: Find scrollbar position on scroll grid

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    90

    Default Find scrollbar position on scroll grid

    Hi, I am trying to get an event to fire when I scroll on my grid component. I wish to know how much is left before it hits the bottom of the scrollbar. I have been trying to look how to do this with no prevail. I feel there is probably an easier way than what I am doing. Appreciate any help

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    The following should work:

    Code:
    grid.getView().el.dom.scrollTop;
    Scott.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    10

    Default FInd scrollbar position

    Hm ... not really, as this gives me the distance (in pixels???) from the top point of the view.
    Nevertheless, I need an information / event in the case that the scrollbar hits the bottom end of the view.

    Any clues here?

    Best

    Adrian

  4. #4
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    Does the following snippet help?

    Code:
    Ext.create('Ext.container.Container', {
        height: 140,
        width: 400,
        autoScroll: true,
        renderTo: Ext.getBody(),
        html: 'a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>'
        , listeners: {
            boxready: function (ct) {
                ct.el.on('scroll', function () {
                    var threshold = ct.el.dom.scrollHeight - ct.el.getScroll().top - ct.el.getHeight();
                    var met = threshold > 100 ? 'greater than 100' : 'less than 100';
                    console.log(met + ' (' + threshold + ')');
                });
            }
        }
    });

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Posts
    10

    Default

    Thanks a lot for the snippet. It works (technically), but it doesnt't deliver the right infromation. It says '100' at approx 90% scroll distance...

    Nevertheless, I'll try to develop on the snippet and see if I can get it to do what I need

    Thanks again

    Adrian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •