Is there a way where setting pointer-events: none can only disable the click on that container but have scroll enable on the same with an overlay.
I have fiddle: https://jsfiddle.net/1eu6d3sq/1/
When I mask, using pointer-events: none, the entire container disables and when I remove this property- all events get enabled.
css:
.parent {
position: relative;
pointer-events: none; /* if I remove this the scrolling works and click is also enabled. if I add this, scrolling and click both get disabled */
}
.button {cursor: pointer}
.main {
height: 80px;
overflow: auto;
}
.mask {
z-index: 1000;
pointer-events: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
cursor: default;
height: 100%;
}
HTML:
<div class="parent"><div class="main">
<div class="aaaa">
Some masked contentThis is some text covered by the maskSome contents above the maskSome contents above the maskSome contents above the maskSome contents above the maskSome ontents above the maskSome ontents above the maskSome ontents above the maskSome ontents aboveThis is some text covered by the maskSome contents above the maskSome contents above the maskSome contents above the maskSome contents above the maskSome ontents above the maskSome ontents above the maskSome ontents above the maskSome ontents aboveThis is some text covered by the maskSome contents above the maskSome contents above the maskSome contents above the maskSome contents above the maskSome ontents above the maskSome ontents above the maskSome ontents above the maskSome ontents above
</div>
<div>This is some text covered by the mask</div>
<div>
<span onclick="function hi(){alert('Hi!')};hi()">clicked SAPN</span>
</div>
<button class="button">
<span class="span-button">OK</span>
</button>
<div class="mask" style="background-color: rgba(255, 255, 255, 0.7);">
<div>
<div>
Some contents above the mask
</div>
</div>
</div>
</div>
</div>
If I understand pointer-events property correctly, it will disable all events triggered.
Here I have added pointer-events to my parent/root element and all subsequent elements inside that parent gets disabled. however how can I make the parent/root DOM element listen only to scroll element?
I tried:
window.addEventListener("scroll", this.onBodyScroll, true);
but onBodyScroll function never gets triggered.
any ideas?
.aaaaelement, not the document - is that what you meant?