Hi,
I’m new to Ionic and I’m trying to displaying images from phone memory (and sdcard) in a Gallery like format - eg Grid with 3 columns. Below is the code that I came up with and I’m having few performance / user experience issues.
View
<div class="row" ng-repeat="image in allImages" ng-if="$index % 3 === 0">
<div class="col col-33" ng-if="$index < allImages.length">
<img ng-src="{{allImages[$index]}}" class="image-list-thumb" ng-click="showImages($index)"/>
</div>
<div class="col col-33" ng-if="$index + 1 < allImages.length">
<img ng-src="{{allImages[$index + 1]}}" class="image-list-thumb" ng-click="showImages($index +1)"/>
</div>
<div class="col col-33" ng-if="$index + 2 < allImages.length">
<img ng-src="{{allImages[$index + 2]}}" class="image-list-thumb" ng-click="showImages($index +2)" />
</div>
</div>
Controller
fs.getImagesNew2().then(function(results){
$scope.allImages.length = 0; //clear existing array;
for (var i = 0; i < results.length; i++) {
//console.log('Image URI: ' + results[i]);
$scope.allImages.push(results[i]);
}
$ionicLoading.hide();
}, function(error){
$ionicLoading.hide();
});
Here are my questions-
-
I’m using
cordova.file.externalRootDirectory
for getting the sdcard path this works in mobiles with internal memory and no slot for sdcard. However, this returns internal path only for phone with external sdcard. Not sure if I need to use someother path.? -
above code works fine for 10 to 25 images. However, if I have around 100+ images then my app crashes. I thought it could be due to too many images binding to UI and causes app to crash. So I used the Lazyload - https://github.com/paveisistemas/ionic-image-lazy-load . This is working but User experience is not good at all. Screen always gets struck for couple of seconds below scrolling down. Could you please advise if I’m doing something wrong. I have been struggling for the past one week on the same issue.
Thanks
Sai