【问题标题】:Infinite scolling with ionic framework使用离子框架进行无限滚动
【发布时间】:2014-04-26 17:44:07
【问题描述】:

我正在为 android 开发一个应用程序,我使用了一个名为“Ionic Framework”的框架。这是我的问题,我必须制作一个具有“ion-infinite-scroll”的无限滚动系统框架的系统。

当我在我的电脑上的 Chrome 上进行测试时,我有 ion-infinite-scroll 尽管我在页面上的位置不会停止。

如何放置我的代码以使系统正常工作?谢谢

控制器

$scope.loadMore = function(){
    console.log("LoadMOre");



    imageCache.init().then(function() {
        BonjourTwitterRepository.populate($scope);
    });
    $scope.$broadcast('scroll.infiniteScrollComplete');
    $scope.$broadcast('scroll.resize');



    console.log($scope.tweetsList);
    if(false){
        console.log("ok");
        $scope.noMoreItemsAvailable = true;

    }
    $scope.currentIndex = $scope.currentIndex + $scope.perPage;

};

存储库

var populateCollection = function (tweets, $scope) {
    collection = new TweetCollection();
    console.log($scope.currentIndex);
    for (var i = $scope.currentIndex; i < $scope.perPage; i++) {
        collection.addTweets(new Tweet(tweets[i], $scope, imageCache));

    }
    $scope.tweetsList = collection;

};

查看

    <ion-item class="item item-body">
        <div class="item item-image">
            <img ng-src="{{tweet.media_url}}" src="img/loading1.gif"/>
        </div>
        <p>
            by : <a href="https//twitter.com/{{tweet.getUsername()}}">@{{tweet.getUsername()}}</a>
        </p>

    </ion-item>
    <div class="item tabs tabs-secondary tabs-icon-left">
        <p>
            <a href="#" class="rating-poll"><i class="icon-thumbs-up"></i></a>
            <a href="#" class="rating-poll"><i class="icon-thumbs-down"></i></a>
        </p>

        <p>
            <button ng-click="shareThis('{{tweet.media_url}}')" class="button icon button-clear "><i
                    class="icon ion-share"></i>Share
            </button>

        </p>


    </div>
</ion-list>
<ion-infinite-scroll></ion-infinite-scroll>

【问题讨论】:

  • 这个if(false)是误会还是?
  • 这只是为了测试代码,如果它是真的变量 $scope.noMoreItemsAvailable = true;循环停止
  • 你确定这是你的全部view.html 吗?顶部缺少&lt;ion-list&gt; 标签。还有什么吗?

标签: javascript android angularjs cordova ionic-framework


【解决方案1】:
<ion-infinite-scroll 
      on-infinite="fetchTrucks()" 
      distance="10%">
</ion-infinite-scroll>

您的无限滚动指令缺少关键属性

这里的例子 http://codepen.io/aaronksaunders/pen/gDrev

【讨论】:

  • Aaron 似乎无限滚动会在加载新数据时将 div 添加到页面中,如果有大量项目,则会产生性能问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-11
  • 2016-03-08
相关资源
最近更新 更多