2016-12-20 3 views
1

私は無限のスクロールにfb-utilを使用しています。しかし、私は250要素を打つと、私は次のエラーが表示されます。どのような考えですか?

Error: Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo(). at Jh (https://www.gstatic.com/firebasejs/3.2.1/firebase.js:431:117) at X.g.Nd (https://www.gstatic.com/firebasejs/3.2.1/firebase.js:441:298) at r._grow (https://<>/content/script/firebase-util.min.js:10:8979) at r._listen (https://<>/content/script/firebase-util.min.js:10:10961) at r.goTo (https://<>/content/script/firebase-util.min.js:10:8062) at r.moveTo (https://<>/content/script/firebase-util.min.js:10:3672) at r.next (https://<>/content/script/firebase-util.min.js:10:17083) at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:198:424 at xa.(anonymous function) (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:59:133) at l.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:126:84)

コード:

var baseRef = firebase.database().ref().child(refPath); 
var scrollRef = new firebase.util.Scroll(baseRef, '$key'); 
scrollRef.scroll.next(25); 
var list = $firebaseArray(scrollRef); 
list.scroll = scrollRef.scroll; 

フロントエンドコード:

<div infinite-scroll="vm.products.scroll.next(10)" infinite-scroll-distance="1"> 

NB:$の優先順位や名または商品コードに$キーからキーを変更するには、エラーを生成する停止しました。しかし、これにより、以前の要素が置き換えられました。だから、

答えて

0

、私は追加のノートに基づいて、質問の最初の部分、のための答えを持っていないが、私はこの修正プログラムを持っている:高い値にmaxCacheSizeとwindowSizeを設定

var scrollRef = new firebase.util.Scroll(baseRef, '$priority', {maxCacheSize: 750, windowSize: 500}); 

を解決する必要があります問題。ドキュメントごとに、windowSizeを超えた場合、配列の先頭がトリミングされ、サイズが制限より小さく保たれます。

ドキュメント:

Keys/values that can be passed via opts: 

{int} windowSize: the maximum number of records to have loaded in the list at any given time. 3-5 times the size of the viewable window is a good optimization, depending on how fast content is scrolled and the payload of each record (i.e. how long it takes to download). 
{int} maxCacheSize: in general, leave this as the default. This controls the internal cursor's cache, which is used to find the current position in the list. This controls how many keys it can load at any given time. This is, by default, three times the size of windowSize and should always be larger than windowSize.