I'm using mcustomscrollbar plugin on a specific area, and I'm having an issue when I add an overlay to this element, I can't scroll the under element. I only can scroll on a blue area, I want to scroll another area as well. I tried to trigger mousewheel event
, but no luck.
Any help very appreciated!
Here is the snippet with my issue:
(function($){
jQuery(window).load(function(){
jQuery(".list").mCustomScrollbar();
});
})(jQuery);
jQuery('.list').mCustomScrollbar({
theme:"dark-3"
});
$(".overlay").on("mousewheel", function(){
jQuery(".list").trigger("mousewheel");
})
.list{
height: 100px;
overflow-y: auto;
overflow-x: auto;
}
.overlay {
position: fixed;
opacity: 1;
visibility: visible;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999;
background-color: rgba(255, 255, 255, .5);
-webkit-transition: opacity .15s ease-out;
-moz-transition: opacity .15s ease-out;
transition: opacity .15s ease-out;
}
.inner-list {
width: 30%;
float:left;
background: lightblue;
position: relative;
z-index: 9999;
overflow: hidden;
}
.question {
position: absolute;
right: 120px;
top: 40px;
}
.row{
list-style-type: none;
overflow: hidden;
width: 200px;
height: 20px;
}
.row:hover{
background-color: #E0EBEE;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://malihu.github.io/custom-scrollbar/3.0.0/jquery.mCustomScrollbar.concat.min.js"></script>
<link href="http://malihu.github.io/custom-scrollbar/3.0.0/jquery.mCustomScrollbar.min.css" rel="stylesheet"/>
<div class="container">
<ul class="list">
<div class="inner-list">
<li class="row" id="1">1</li>
<li class="row" id="2">2</li>
<li class="row" id="3">3</li>
<li class="row" id="4">4</li>
<li class="row" id="5">5</li>
<li class="row" id="6">6</li>
<li class="row" id="7">7</li>
<li class="row" id="8">8</li>
<li class="row" id="9">9</li>
<li class="row" id="10">10</li>
<li class="row" id="11">11</li>
<li class="row" id="12">12</li>
<li class="row" id="13">13</li>
<li class="row" id="14">14</li>
<li class="row" id="15">15</li>
<li class="row" id="16">16</li>
<li class="row" id="17">17</li>
<li class="row" id="18">18</li>
<li class="row" id="19">19</li>
<li class="row" id="20">20</li>
</div>
</ul>
<p class="question">Why can't scroll here?</p>
<div class="overlay"></div>
</div>
the problem is with .overlay
, it is above the content so user action is disabled. you can simple use pointer-events: none
for it. it doesn't work for IE11 so you can use display: inline-block
as well to make it work for IE11.
.overlay {
pointer-events: none;
display: inline-block
}