2016-10-05 32 views
0

我正在開發應用程序,其中有飼料或一些時間表。這裏是我的NG-重複碼:離子滾動性能問題

<div ng-repeat="x in feeds" class="fd-feed-card"> 
    <div class="fd-feed-usr-img"> 
     <img ng-src="{{x.user.media[0].small}}" class="fd-img fd-img-br border-style"> 
    </div> 

    <div class="ft-16 fd-feed-usr-name"> 
     <span><b>{{x.user.name}}</b></span><span class="ft-12 fd-feed-created-time plx prm">{{x.feed.createdTimeStamp | readableTime}}</span> 
    </div> 
    <div ng-style="imgStyle"> 
     <img ng-src="{{x.feed.media[0].medium}}" class="fd-img objectcover image-blur"> 
    </div> 
    <div ng-if="x.feed.total_comments > 0 || x.feed.total_likes >0"> 
     <p class="mll"><span on-tap="openCommentModal(x.feed._id, $index, x.feed)" class="prm" ng-if="x.feed.total_comments > 0">{{x.feed.total_comments}} Comment</span><span ng-if="x.feed.total_likes>0" on-tap="openUserModal(x.feed._id)">{{x.feed.total_likes}} Likes</span> 
     </p> 
    </div> 
    <div class="fd-feed-distance"> 
     <span class="plx prm ft-16">{{x.distance}} <span class="ft-10">mil</span></span> 
    </div> 
</div> 

這裏的每一個飼料中包含用戶名,userimage和飼料和距離400*400px圖像。該即時通訊使用離子無限滾動像這樣經過:

<ion-infinite-scroll on-infinite="getDashboardFeed()" distance="1%" ng-if="!noMoreFeedContent"></ion-infinite-scroll> 

在我的javascript代碼,我打電話與具有5一次送入分頁API。這裏是我的javascript代碼:

$scope.getDashboardFeed = function(start) { 
    var _start = start || false; 
    var params = {} 
    params.offset = offset; 
    params.limit = limit; 
    Posts.getAllFeeds(params).success(function(res) { 
      if (_start) { 
       $scope.feeds = []; 
      } 
      if (res.data.length < limit) { 
       $scope.noMoreFeedContent = true; 
      } else { 
       $scope.noMoreFeedContent = false; 
      } 

      for (var i = 0; i < res.data.length; i++) { 
       var markerPos = new google.maps.LatLng(res.data[i].feed.location[0], res.data[i].feed.location[1]); 
       var currentLatLng = new google.maps.LatLng(res.data[i].location.location[0], res.data[i].location.location[1]) 
       var distance = google.maps.geometry.spherical.computeDistanceBetween(markerPos, currentLatLng) * 0.000621371; 
       res.data[i].distance = distance.toFixed(2); 
       for (var j = 0; j < res.data[i].feed.likes.length; j++) { 
        if (uid == res.data[i].feed.likes[j].user) { 
         res.data[i].isLiked = true; 
         break; 
        } else { 
         res.data[i].isLiked = false; 
        } 
       } 
       $scope.feeds.push(res.data[i]); 

      } 

      offset = offset + limit; 
      if (_start) { 
       $scope.$broadcast('scroll.refreshComplete'); 
      } else { 
       $scope.$broadcast('scroll.infiniteScrollComplete'); 
      } 
     }) 
     .error(function(err) { 

     }) 
}; 

即時通訊也計算基於當前位置的每個飼料的距離。並檢查我是否喜歡這個帖子。

現在的問題是,當飼料加載到25,30,滾動變得滯後在我的機器人。林還利用本link給本土滾動,

我已閱讀也更喜歡博客this

,但我沒有得到太多的幫助。我必須在這裏加載1000個Feed,每個Feed包含400 * 400px的圖片。

我也試過收集重複。它也沒有工作。

有沒有其他方法可以嘗試修復我的滾動性能? 有人可以幫助我嗎?

回答

0

我有同樣的問題,特別是在ng-repeat中使用圖像時。我的回答here