I have scrollable list and want to show scrollbar only by hover, but I also want to have ability to scroll by first touch on list on mobile browsers (iOS, Android) — behaviour like list always has overflow-y: auto
. I try to use this code (http://codepen.io/sergdenisov/pen/RPazyg):
HTML:
<ul class="list js-list">
<li>Test Test Test Test Test Test Test Test Test</li>
...
<li>Test Test Test Test Test Test Test Test Test</li>
</ul>
CSS:
.list {
-webkit-overflow-scrolling: touch;
padding: 0 30px 0 0;
overflow: hidden;
height: 300px;
width: 300px;
background: gray;
list-style: none;
}
.list_scrollable {
overflow-y: auto;
}
Javascript:
$('.js-list').on({
'mouseenter touchstart': function() {
$(this).addClass('list_scrollable');
},
'mouseleave touchend': function() {
$(this).removeClass('list_scrollable');
}
});
But scroll ability on mobile browsers activates only by additional tap on list before scrolling. Have any ideas?