Ionic 3 virtual scroll only displays a small part of the items - angularjs

I'm having trouble with the Ionic 3.3.0 virtual scroll due to the fact that I have a ~360 items array and it only displays the first 15 on the phone. Has anyone encountered this issue?
P.S.: The virtual scroll list is in a container that has 35% of the screen height. Don't know if this has an effect on the issue or not...
this.friendsList = [{name: 'John'},...,{name: 'Zed'}];
<div class="friends-list__container">
<ion-list [virtualScroll]="friendsList">
<ion-item *virtualItem="let friend">
{{friend.name}}
</ion-item>
</ion-list>
</div>

After researching the issue, it seems that the solution was to add an extra DIV wrapper around the virtual scroll list:
<div class="friends-list__container">
<div> <!-- This is needed for the virtual scroll to work properly -->
<ion-list [virtualScroll]="friendsList">
<ion-item *virtualItem="let friend">
{{friend.name}}
</ion-item>
</ion-list>
</div>
</div>

Related

ionic expand and collapse with button tap

I'm using ionic and angularJS in my application, I need to expand and collapse list view. As of now I created the list view using ion-list and ion-item without expand and collapse. Please find the code and snap below.
<ion-view view-title="Call Lists">
<ion-content class="padding">
<ion-list show-delete="false" can-swipe="true">
<div class="list card-ScheduledCalls">
<!-- Task # -->
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="item in callItems" type="item-text-wrap" ng-click="doTask()">
<img ng-src="{{item.imgSrc}}">
<h3>{{item.callCount}}</h3>
<h3>{{item.callDate}}</h3>
<p style="color:white;">{{item.callCmt}}</p>
<p style="color:white;">{{item.callType}}</p>
<p style="color:white;">{{item.assetType}}</p>
<p style="color:white;">{{item.requestedBy}}</p>
<p style="color:white;">{{item.issueType}}</p>
</ion-item>
</div>
</ion-list>
</ion-content>
</ion-view>
Now I have more details in the each list for eg: EmpName, BloodGroup, EmpTodayTaskName, TaskTime, TaskDuration, TaskComments, etc. First I will show only three fields in the list, If a user clicks the more button (mentioned in the image) I will show remaining details.
At the same time, I'm having tapping (ng-click) functionality to go next page so I restrict the user that If they select the more button only to do expand and collapse other touches it will move into next page.
How can I handle this activity in ionic and angular ?
If I understand this correctly, the app needs to go to the next page if the content inside of the ion-item is clicked. If so, why not to wrap ion-item content inside some container, for example div, and attach the required ng-click there

Ionic collection-repeat affecting active classes

I have ng-class inside of my ion-list if the user clicks an item it adds the class selected. The problem when using collection-repeat is its managing the DOM and changing the selected class as I scroll.
<ion-list>
<ion-item collection-repeat="contact in contacts | filter:filters" class="contact" ng-click="pickContact($index, $element, this.contact)" ng-model="contactModel" ng-class="{'selected': contact.selectedContact}" toggle-contacts="selected" collection-item-height="150" collection-item-width="'33.3%'">
<div ng-if="contact.photo.type == 'img'" class="contact-img">
<img ng-src="{{contact.photo.value}}.png" alt="">
</div>
<div ng-if="contact.photo.type == 'text'" class="contact-text-placeholder">
{{contact.photo.value}}
</div>
<div class="contact-name">
{{contact.name}}
</div>
</ion-item>
</ion-list>
How can I avoid this from happening? I want the class to stick.
The solution was to add the class into the data itself.

Ng-repeat and Native scrolling creating issue with scope loading

I am creating hybrid application and i am facing issue in ng-repeat with native scrolling.
Below are my template file code
<ion-view align-title="center">
<ion-content class="ionic headerWithNav" overflow-scroll='true'>
<ul>
<li ng-repeat="lessondata in AllLessonComing" ng-class="{true: 'showBg', false: ''}[(AllLessonComing).length>0]" ng-click="lessondetailsPage('{{lessondata.id}}')">
<div class="lesson-wrap">
<div class="lesson-img">
<div class="lession-price"> <span>{{lessondata.price}}</span> </div>
<div class="lessonImg-wrap"><img image-lazy-src="{{lessondata.image}}" lazy-scroll-resize="true" image-lazy-loader="bubbles" class="ink" on-finish-render="ngRepeatFinished"/></div>
</div>
<div class="lessonInfo">
<div class="row">
<div class="col col-67">
<h1>{{lessondata.title}}</h1>
<div class="lesson-status">{{lessondata.category_name}}</div>
<div class="row">
<div class="col lesson-location">{{lessondata.City}}</div>
<div class="col">
<div class="lesson-rating"><img src="img/start-rating.jpg"></div>
</div>
</div>
</div>
<div class="col padr-none">
<div class="trainnerImg-wrap">
<div class="trainee-img"> <img src="{{lessondata.coach_image}}"> </div>
<div class="trainee-name">{{lessondata.coach_name}}</div>
</div>
</div>
</div>
</div>
</div>
</li>
<li ng-show="(AllLessonComing).length == 0">
<div class="inner-container"><div class="no-results">No Lesson Found</div></div>
</li>
</ul>
</ion-content>
</ion-view>
As you can see i am using "overflow-scroll='true'" for native scrolling and ng-repeat for the showing my lessons.
This is an image when scope data render first time--
when scope data render first time
And this is an image when i scroll speedily when i scroll speedily
ISSUE:- I don't know why these images and text are reloading or flickering when i scroll speedily
My Code is correct.
ng-repeat was creating issue with the ionic 1.0. Now ionic released new version that is ionic 1.2 and you will see that this issue has been resolved by ionic's developers.
you can update your ionic version easily.
If you are using NPM then use this command
ionic lib update
Check brower.JSON file in www/lib/ionic/ folder. if brower.JSON exists then remove this file.
you will see the mazik of ionic 1.2.
This issue happens on hybrid app. The longer list (and images) the more lag it has. As I can see you are using Ionic, try to use ion-list instead. It could help create a better list view.
p/s: sorry I was not able to made a comment (not enought rep point). So I post it here. Hope it help!
Two more suggestion:
Use angular bindonce to reduce $watchers and faster render
If you are building your app using ionic build for Android, you could use built-in Crosswalk for a stronger webview of your app

ionic content with scroll

I have a view in ionic which has an image at the top and a scrollable list of messages. I want the image to stay on the screen while the list can be scrolled. Here is my current code:
<ion-content scroll="false">
<img src="/myimage.png">
<ion-scroll direction="y" style="height: auto;" delegate-handle="postScroll">
<div class="list">
<a class="item item-avatar" ng-repeat="post in posts">
<img ng-src="myimage.png">
<h2>{{post.title}}</h2>
<p>{{post.content}}</p>
</a>
</div>
</ion-scroll>
</ion-content>
This works pretty well, i.e. the scroll does work and the image stays in place. But I am having trouble setting the height. If I have 100 posts, for example, I can only see 2-3 since the height container is not nearly large enough. Am I doing this correctly? How can I set a variable height for the number of posts? The user can add posts dynamically so this height needs to be able to change.
I leave these codepen which will help you!
<ion-scroll direction="x" zooming="false" delegate-handle="horizontal2" horizontal-scroll-fix="mainScroll">
example 1
example 2

Ionic Accordion Reflow

I am using the Ionic Accordion List from here and I have an issue with the screen height (this official example also has that problem), when you open an accordion the screen height remains the same as before when it was closed so when you try to scroll it doesn't go further down for example.
If you try a second time to scroll usually it does but other times you need to touch-drag a specific area so you can scroll.
<ion-list>
<div ng-repeat="group in groups">
<ion-item class="item-stable"
ng-click="toggleGroup(group)"
ng-class="{active: isGroupShown(group)}">
<i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
Group {{group.name}}
</ion-item>
<ion-item class="item-accordion"
ng-repeat="item in group.items"
ng-show="isGroupShown(group)">
{{item}}
</ion-item>
</div>
</ion-list>
Its been very long and not sure whether you already fixed this issue.
Based on my understanding, i think that there is some delay in triggering the resize event.
Not sure about the permanent solution but for temporarily we have the invoke by $ionicScrollDelegate.resize().
I hope this works for you and please let me know if am wrong. Also please do share if you find any alternative solution for this problem.
I was experiencing a similar accordion reflow issue and was able to resolve the same by calling $ionicScrollDelegate.resize() in the accordion toggle (show/hide) function.

Resources