2

I am not able to get the scroll bar working for a div element. It works fine in all browsers, the issue is only on Salesforce1 app.

Any help would be great.Thanks in advance.

<aura:component>
<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/    </head>  
  <body>
        <div style="height: 130px;width: 200px;background-color:green;margin-right: 20px;overflow-y:scroll;-webkit-overflow-scrolling: touch;">
            <p> test</p>
            <p> test</p>
            <p> test</p>
            <p> test</p>
            <p> test2</p>
            <p> test</p>
            <p> test</p>
            <p> test4</p>
            <p> test</p>
            <p> test</p>
            <p> test5</p>
        </div>
</body>
</aura:component>

3 Answers 3

0

I am not sure if the disappearing scroll bar is related to your view dimension. Try add this in your component's stylesheet. You can adjust the max-width to have a good view on tablets/phones

@media(max-width: 1600px){
    .THIS.container{
        width: 90%;
    }
}
0

Standard HTML "overflow:scroll" doesn't work in Lightning components.

But workaround is you can create a scrollDiv around your div in component and set the following in your css to make it work.

 .THIS div.scrollDiv {
    width: 100%;
    overflow-y: auto;
}
0

You can use newly added Lightning component in the Winter '17, ui:scrollerWrapper that enables native scrolling in Lightning Components Salesforce1 app as well as in Lightning Desktop.

A ui:scrollerWrapper creates a container that enables native scrolling in Salesforce1. This component enables you to nest more than one scroller inside the container. Use the class attribute to define the height and width of the container.

Please find the code below:

Component:-

<aura:component implements="force:appHostable, flexipage:availableForAllPageTypes">
    <div class="mainWrap">
        <ui:scrollerWrapper class="sWrapTest">
            <ul class="testDiv">        
               <li>In the Winter ’17 release, many of your favorite features 
                   are easier to use than ever before. 
               </li>
               <li>Lightning Experience has a brand new                      
                   navigation bar and lots of critical sales,
                   service, and analytics capabilities. 
               </li>
               <li>You’ve got more options for managing customer and partner
                   communities, running your business from your phone, 
                   and keeping your data and your users secure. 
               </li>
               <li>Not to mention plentiful new
                   customization and app development features, 
                   including custom Lightning apps.
               </li>                      
               <li>Other features require direct action by an administrator 
                   before users can benefit from the new functionality.
               </li>
               <li>If a key feature is also available in Salesforce1, 
                   our mobile app, we mention that in the feature description. 
               </li>
               <li>ui:scrollerWrapper
                   Creates a container that enables native scrolling in 
                   Salesforce1.
               </li>

            </ul>
        </ui:scrollerWrapper>
    </div>
</aura:component>

Style:-

.THIS .sWrapTest {
    height:100px;
    width:100px;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .