10000 Scroll not working on normalized collection · Issue #83 · googlearchive/firebase-util · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.

Scroll not working on normalized collection #83

Open
laurensnl opened this issue Jan 12, 2016 · 1 comment
Open 8000

Scroll not working on normalized collection #83

laurensnl opened this issue Jan 12, 2016 · 1 comment

Comments

@laurensnl
Copy link

I've got an issue with infinite scrolling a list with a normalized collection.

The initial data is loaded correctly, but no subsequent data is loaded on scroll, but no more data is loaded when scrolling down. Infinite scrolling does work when I replace the normalized collection ref to a standard Firebase ref. What am I doing wrong here?

// map the paths we are going to join
var norm = new Firebase.util.NormalizedCollection(
    FB.child('sessions'),
    [FB.child('accounts'), 'accounts', 'sessions.user']
);

// specify the fields for each path
norm = norm.select( 'sessions.user', 'sessions.loginTime', 'sessions._sort', ... );

// get a reference we can use like a normal Firebase instance
var scrollRef = new Firebase.util.Scroll(norm.ref(), '_sort');

firebase#2.2.9
firebase-util#0.2.6

@laurensnl
Copy link
Author

The above seems only be the case when using a NormalizedCollection as a Scroll ref as a data source for ui-grid (version 1.7.2). The rest of my code looks like this:

// UI grid data
vm.sessions.data = $firebaseArray(scrollRef);

// load 50 records initially
scrollRef.scroll.next(50);

vm.sessions.onRegisterApi = function(gridApi){

    // filter
    gridApi.core.on.filterChanged( $scope, function() {
        var grid = this.grid;

        if( grid.columns[0].filters[0].term === '' ) {
            vm.sessions.data = $firebaseArray(scrollRef);
        } else {
            vm.sessions.data = $firebaseArray(FB.child('sessions').orderByChild('displayName').startAt(grid.columns[0].filters[0].term).endAt(grid.columns[0].filters[0].term + '~'));
        } 
    });

    // scroll down
    gridApi.infiniteScroll.on.needLoadMoreData($scope,function(){
        console.log('more');
        scrollRef.scroll.next(50);
    });

    // scroll up
    gridApi.infiniteScroll.on.needLoadMoreDataTop($scope,function(){
        scrollRef.scroll.prev(50);
    });

    vm.sessions.data.$watch(function() {
        $scope.$evalAsync(function() {
            gridApi.infiniteScroll.dataLoaded();
        });
    });
};

Anyone who has experience with this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
39B1
Projects
None yet
Development

No branches or pull requests

1 participant
0