この Angular スクリプトは API からコンテンツを取得します。ソースからコンテンツ全体を一度に取得しないように ngInfiniteScroll を実装しました。2 番目のページをロードするために ngInfiniteScroll 関数が起動すると、コンテンツのロードがほんの一瞬ですが、div 全体が消えます。理由はありますか?
実際の例
http://nolayout.com/archive/index-2.html
Angular スクリプト
var app = angular.module('arenaApp', ['ngResource', 'ngSanitize', 'infinite-scroll']);
app.controller('channelShow', function($scope, $resource, $routeParams, $rootScope) {
var Channel = $resource('http://api.are.na/v2/channels/:slug/contents');
$scope.channel = [];
var channel = Channel.get({ slug: 'no-layout-archive', per: 20, sort: 'position', direction: 'asc' }, function() {
$scope.channel = channel;
});
$scope.busy = false;
$scope.page = 1;
$scope.appendContents = function() {
if ($scope.busy) return;
$scope.busy = true;
$scope.page++;
var channel = Channel.get({ slug: 'no-layout-archive', per: 20, page: $scope.page, sort: 'position', direction: 'asc' }, function() {
$scope.channel = channel;
$scope.busy = false;
});
}
});
HTML
<div class="container" infinite-scroll="appendContents()" infinite-scroll-disabled="busy" infinite-scroll-distance="1" >
<div ng-repeat="block in channel.contents | filter:query" >
<div ng-if="block.class == 'Image'">
<div class="seven columns add-bottom imgnormal">
<img src="{{block.image.original.url}}" alt="{{block.title}}">
</div>
</div>
</div>
<div ng-show="busy">Loading</div>
</div>