I would like to swipe sideways between sections of a questionnaire. Each section has a header and a number of answered questions. I would like to add a vertical scroll on the questions, but can't figure out how to get it working. Here is my view:
<ion-view title="{{vm.title}}">
<ion-slide-box show-pager="true" class="has-header">
<ion-slide ng-repeat="s in vm.sections">
<ion-item class="item-royal">
{{s.Heading}}
</ion-item>
<ion-scroll>
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</ion-scroll>
</ion-slide>
</ion-slide-box>
</ion-view>
I found a solution that fixes the specific problem I was having, but creates another. I added a div to the ion-scroll and set heights on the ion-scroll and the new div:
<ion-scroll style="height:300px">
<div style="height:100%">
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</div>
</ion-scroll>
This causes two problems:
I don't want to specify the height of the ion-scroll in pixels - I'd like it to fill the remaining space in the window.
The pager appears in front of the scroll window - I'd like it to appear below.
EDIT Then I found a second solution:
<ion-view title="{{vm.title}}">
<ion-slide-box show-pager="true" class="has-header"
style="position:absolute; bottom: 0;left: 0;right: 0; ">
<ion-slide ng-repeat="s in vm.sections">
<ion-item class="item-royal">
{{s.Heading}}
</ion-item>
<ion-content>
<div class="card" ng-repeat="q in s.Questions">
<div class="item item-divider">
{{q.Text}}
</div>
<div class="item">
{{q.Answer}}
</div>
</div>
</ion-content>
</ion-slide>
</ion-slide-box>
</ion-view>
Changes made
Set the style of the ion-slide-box to position:absolute; bottom: 0;left: 0;right: 0; (The top is already specified by the has-header class)
Use ion-content around the part I want to scroll instead of the ion-scroll and the div
Live with the pager in front. It looks fine!
Edit 2
I'd also recommend using Crosswalk if you are having scroll problems with older Android devices.
For Ionic 4 get it to scroll vertically with some css.
<ion-slide><div class="scrollVertically">stuff to scroll...</div></ion-slide>
.scrollVertically{
overflow: auto;
height: 100vh;
}
I have solved this with this simple css:
ion-slides { height: initial; }
For ionic 2, you need to use <ion-slides>. <ion-slide-box> has been deprecated.
Related
I'm trying to add a transition where a user clicks on a button and the next page slides in from the right side.
Is that easy to do with the Ionic Framework?
I can't seem to find how to do that.
Here is what I have on my view:
<ion-view title="Payment" cache-view="false">
<ion-content padding="false" class="has-header">
<div class="container">
<div class="spacer" style="width: 290px; height: 31px;"></div>
<div class="show-list-numbers-and-dots">
<p style="color:#000000;">Payment Methods</p>
</div>
</div>
<ion-list>
<ion-item class="item-icon-left item-icon-right">
<i class="icon ion-card"></i>.... 2039
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item class="calm" ui-sref="paymentPage">Add Payment Method</ion-item>
</ion-list>
<div class="spacer" style="width: 290px; height: 44px;"></div>
</ion-content>
</ion-view>
check this from official docs
slides component
First disable swipe and then on button click you can call this function for transition
slideTo(index, speed, runCallbacks)
When I try to dynamically add content in MODAL(overflow-scroll is set false), the page adds white space at the bottom of page and prevents me to scroll up to reach the top of "ion-content".
Can anyone help me?
My code:
<ion-modal-view>
<ion-header-bar>
....
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item ng-repeat="fc in query.filterChoices">
...
</ion-item>
</ion-list>
<div class="row">
<div class="col col-20">
</div>
<div class="col col-60">
<button class="button button-stable button-block" ng-click="addFilterChoice();">
Add Filter
</button>
</div>
<div class="col col-40">
</div>
</div>
</ion-content>
I need a scrollable page with ion-slides directive. If i set scroll=true in ion-content the slider is not shown on the page. I'm running ionic 1.3.1 and using the new ion-slide directive. This is my code,
<ion-content class="padding" scroll="false">
<div class="list card">
<div class="item no-padding">
<img class="full-image" src="http://12.jpg">
</div>
<div class="item ">
<button class="button icon-left ion-android-navigate button-stable">Directions </button>
<button class="button icon-left ion-ios-telephone button-stable">Call </button>
<button class="button icon-left ion-android-share-alt button-stable">Share</button>
</div>
</div>
<div class="slide-wrapper1">
<ion-slides options="options" slider="data.slider">
<ion-slide-page>
<img src="http://placehold.it/375x468/">
</ion-slide-page>
<ion-slide-page>
<img src="http://placehold.it/375x468/0000">
</ion-slide-page>
<ion-slide-page>
<img src="http://placehold.it/375x468/">
</ion-slide-page>
</ion-slides>
</div>
<h4>About </h4>
<div class="card">
<div class="item item-text-wrap">
This is a basic Card which contains an item that has wrapping text.
</div>
</div>
</ion-content>
what am i doing wrong, How do i get the ion-slides to work in a scrollable page?
Thanks for any help
How about wrapping the inside of your ion-slide-page with an ion-content like:
<div class="slide-wrapper1">
<ion-slides options="options" slider="data.slider">
<ion-slide-page>
<ion-content has-header="true" padding="true">
<img src="http://placehold.it/375x468/">
</ion-content>
</ion-slide-page>
</ion-slides>
</div>
I would like to note that this should work with Android. I think I had to remove the ion-content for iOS to work on the device.
*Edit - Also, my outside ion-content is set to true
I have a fairly simple template for ion-item cards:
<ion-list>
<div class="card">
<ion-item ng-repeat="item in items"
item="item"
ui-sref="main.tabs.create({id: item.id})">
<div class="item item-avatar item-fill-space">
<img data-ng-src="data:image/jpg;base64,{{ item.image[0] }}" data-err-src="../../../../../res/icons/android/icon-48-mdpi.png">
<h2>{{ item.title }}</h2>
</div>
<div class="item item-body item-fill-space">
{{ item.message }}
</div>
</ion-item>
</div>
<ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="10%"></ion-infinite-scroll>
</ion-list>
It's appearing like this on the screen:
The horizontal line in the middle isn't reaching the full width of the container (with respect to the margin on the opposite side). How can I fix this?
I've tried adding the class
.item-fill-space {
width: 100%;
}
but it doesn't work unless I specify a width of more than 100%, but that's a bit hacky.
I have the same problem, with a similar code:
<ion-view>
<ion-content>
<ion-list>
<ion-item ng-repeat="aviso in avisos | filter: filter" href="#/app/avisos/{{aviso.id}}">
<div class="item item-divider aviso">
<strong>{{aviso.create_date | dateFormat}}</strong>
</div>
<div class="item aviso">{{aviso.formated_message}}</div>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
And, like DaveDev said, the only workaround solution is to use a width of more then 100% (in my case, 110% worked for the "aviso" class). But I'm not happy with this too.
'ion-content' comes with padding into it.
Try and see what happens when you take out that padding in your outer directive which contains your 'ion-list'.
I'm working on an Ionic project and in one of our views we have an input field in the sub-header. Using this input field a user can search for other users which are displayed in an ion-list.
The problem I'm experiencing is that when the keyboard appears it's actually hiding part of the ion-list. After reading the Keyboard documentation from the Ionic docs, I believe the problem is caused because the sub-header input field and the ion-list are not part of the same scrollable area.
Is there any way I can solve this issue?
Here are the relevant parts of the code:
<ion-header-bar align-title="left" class="bar-light bar-subheader item-input-inset">
<div class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="searchUsers" ng-change="showUsersSuggestions($event);" ng-focus="enableSearch(true)" ng-blur="enableSearch(false)">
<button class="button button-clear clear-search icon ion-ios-close-empty" ng-click="clearSearch()"></button>
</div>
</ion-header-bar>
<ion-content>
<ion-list can-swipe="true" ng-if="showSearchResults">
<ion-item class="item item-divider list-result" style="border-top:0;">
Search results
</ion-item>
<ion-item class="item item-avatar item-icon-right item-text-wrap list-result" ng-show="searchUsers && searchUsers.length >= 3 && usersSuggestions" ng-repeat="f in usersSuggestions">
<img ng-src="{{getAvatarUrl(f)}}" width="40" height="40" ng-click="showProfileInfo(f)">
<h2 ng-show="f.displayName" ng-click="showProfileInfo(f)">{{f.displayName}}</h2>
<p ng-click="showProfileInfo(f)">{{f.email}}</p>
</ion-item>
</ion-list>
......
</ion-content>
The only way i found to solve this is to close the keyboard on content touch event..
<ion-content class="has-subheader" on-touch="hideKeyboard()">
...
</ion-content>
scope.hideKeyboard = function() {
$cordovaKeyboard.close()
};
...
</ion-content>
<div keyboard-attach>
</div>
</ion-view>
I just added this div with keyboard-attach. The ionic documentation says keyboard-attach works just with a footer but it worked for me. I tested on iOS9.