Skip to content

Commit 3d7b6c7

Browse files
committed
Add wheelPropagationDisabledIfScrollable option
1 parent c3354c0 commit 3d7b6c7

13 files changed

+124
-27
lines changed

dist/perfect-scrollbar.common.js

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.esm.js

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.js

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/perfect-scrollbar.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/options-wheelPropagation.html

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@
4444
font-size: 20px;
4545
}
4646

47+
.container .content-no-scroll {
48+
background-image: url('https://mdbootstrap.com/img/Marketing/general/logo/big/mdb.png');
49+
width: 12800px;
50+
height: 200px;
51+
color: blue;
52+
font-size: 20px;
53+
}
54+
55+
.container .smaller-font-size {
56+
font-size: 12px;
57+
}
58+
4759
.space {
4860
padding: 150px 0;
4961
text-align: center;
@@ -94,18 +106,42 @@ <h1>Wheel Propagation</h1>
94106

95107
<br>
96108
<div class="space my-5">FOR SPACE</div>
109+
<div class="container">
110+
<div class="content-no-scroll">
111+
<div class="alert alert-primary sticky-top font-weight-bold m-5" role="alert" style="z-index: 10; width:300px">
112+
Default (not scrollable)
113+
</div>
114+
</div>
115+
</div>
116+
<div class="space my-5">FOR SPACE</div>
97117
<div class="container">
98118
<div class="content">
99119
<div class="alert alert-primary sticky-top font-weight-bold m-5" role="alert" style="z-index: 10; width:300px">
100-
Default
120+
Default (scrollable)
101121
</div>
102122
</div>
103123
</div>
104124
<div class="space my-5">FOR SPACE</div>
105125
<div class="container">
106126
<div class="content">
107127
<div class="alert alert-primary sticky-top font-weight-bold m-5" role="alert" style="z-index: 10; width:300px">
108-
wheelPropagation: true
128+
wheelPropagation: false
129+
</div>
130+
</div>
131+
</div>
132+
<div class="space my-5">FOR SPACE</div>
133+
<div class="container">
134+
<div class="content-no-scroll">
135+
<div class="alert alert-primary sticky-top font-weight-bold m-5 smaller-font-size" role="alert" style="z-index: 10; width:300px">
136+
wheelPropagationDisabledIfScrollable: true<br>(not scrollable)
137+
</div>
138+
</div>
139+
</div>
140+
<div class="space my-5">FOR SPACE</div>
141+
<div class="container">
142+
<div class="content">
143+
<div class="alert alert-primary sticky-top font-weight-bold m-5 smaller-font-size" role="alert" style="z-index: 10; width:300px">
144+
wheelPropagationDisabledIfScrollable: true<br>(scrollable)
109145
</div>
110146
</div>
111147
</div>
@@ -119,11 +155,19 @@ <h1>Wheel Propagation</h1>
119155
var containers = document.querySelectorAll('.container');
120156

121157
new PerfectScrollbar(containers[0]);
158+
new PerfectScrollbar(containers[1]);
122159

123-
new PerfectScrollbar(containers[1], {
124-
wheelPropagation: true
160+
new PerfectScrollbar(containers[2], {
161+
wheelPropagation: false
125162
});
126163

164+
new PerfectScrollbar(containers[3], {
165+
wheelPropagationDisabledIfScrollable: true
166+
});
167+
168+
new PerfectScrollbar(containers[4], {
169+
wheelPropagationDisabledIfScrollable: true
170+
});
127171
</script>
128172

129173

src/handlers/keyboard.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ export default function(i) {
1313
const scrollTop = Math.floor(element.scrollTop);
1414
if (deltaX === 0) {
1515
if (!i.scrollbarYActive) {
16-
return false;
16+
return !i.settings.wheelPropagationDisabledIfScrollable;
1717
}
1818
if (
1919
(scrollTop === 0 && deltaY > 0) ||
2020
(scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)
2121
) {
22+
if (i.settings.wheelPropagationDisabledIfScrollable) {
23+
return true;
24+
}
25+
2226
return !i.settings.wheelPropagation;
2327
}
2428
}

0 commit comments

Comments
 (0)