Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic 3.2 - How to disable scroll of ion-content?

I am developing an app in Ionic 3.2 version. I have a ion-refresher inside ion-scroll. I want to disable scrolling of ion-content and want to show the ion-refresher inside the ion-scroll when scroll the ion-list. But it fails.

  • I tried no-bounce (<ion-content no-bounce>) and disable-scroll (<ion-content disable-scroll>) but still content is scrolling
  • I tried to put ion-fixed inside content and inside a div just below the content. But then the ion-refresher not working.
  • I tried scroll="false" (like in ionic 1.0) but still scrolling

Below the code;

    <ion-content scroll="false">
    <ion-scroll scrollY="true" style="width: 100% !important;height:30% !important"> 
        <ion-refresher (ionRefresh)="fill_data($event)">
          <ion-refresher-content pullingIcon="arrow-dropdown" pullingText="{{ 'pull_to_refresh' | translate }}" refreshingSpinner="circles"
            refreshingText="{{ 'refreshing' | translate }}">
          </ion-refresher-content>
        </ion-refresher> 
        <ion-list>
          //data filling here
        </ion-list>
      </ion-scroll>
    </ion-content>

Please help me...

like image 391
Tony Avatar asked May 25 '17 08:05

Tony


People also ask

How do I disable scroll in ion content?

Example 1 - Try a setting <content scroll="false"> that will disable scrolling. This every time an event is called, in our case, on every drag event.

How do I stop CSS from scrolling?

Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.

How do you scroll in ionic?

ion-scroll Scroll is a non-flexboxed scroll area that can scroll horizontally or vertically. ion-Scroll Can be used in places where you may not need a full page scroller, but a highly customized one, such as image scubber or comment scroller.

What does ion content do?

The Ionic framework provides an <ion-content> element that serves as a container which wraps all the other elements that we want to create in the app. The content component allows an easy to use content area that contains some useful methods to control the scrollable area.


3 Answers

This is how I did it just now - same problem as you @Tony

With this SCSS my list scrolls, and I can have items below it:

page-home {
  .scroll-content {
    overflow: hidden;
  }

  ion-list {
    overflow-y: auto;
    max-height: 72vh;
  }
}

I tried using the ionic scroll and other options but none seem to work right now.

like image 100
Evan Shortiss Avatar answered Nov 11 '22 16:11

Evan Shortiss


.scroll-content {
    overflow-y: hidden !important;
}

this worked for me

like image 22
Zhang Bruce Avatar answered Nov 11 '22 16:11

Zhang Bruce


use in the sass file of the page ..it works for me

.scroll-content {
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    position: absolute;
    z-index: 1;
    display: block;
    overflow-x: unset;
    overflow-y: unset;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    contain: size style layout;
}
like image 25
Alex Avatar answered Nov 11 '22 15:11

Alex