Skip to content

Commit 1b51bd9

Browse files
committed
Make the perspective container match the scrollable content height.
1 parent 0a950d1 commit 1b51bd9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

custom-scrollbar/scrollbar.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
(function(scope) {
2-
document.body.style.transform = 'translateZ(0)';
32
var dragging = false;
43
var lastY = 0;
54

@@ -31,6 +30,7 @@
3130
// the amount of overflow.
3231
function updateThumbSize(scrollable) {
3332
var thumb = scrollable.thumb;
33+
scrollable.perspectiveCtr.style.height = scrollable.scrollHeight + "px";
3434

3535
var viewport = scrollable.getBoundingClientRect();
3636
var scrollHeight = scrollable.scrollHeight;
@@ -85,7 +85,10 @@
8585
perspectiveCtr.style.perspectiveOrigin = "top right";
8686
perspectiveCtr.style.transformStyle = "preserve-3d";
8787
perspectiveCtr.style.width = "100%";
88-
perspectiveCtr.style.minHeight = "100%";
88+
// TODO: Put content into perspective container so that it automatically
89+
// gets the scrollable content height from its descendants, as right now it
90+
// will not detect changes to content size.
91+
perspectiveCtr.style.height = scrollable.scrollHeight + "px";
8992
perspectiveCtr.style.position = 'absolute';
9093
perspectiveCtr.style.pointerEvents = 'none';
9194
perspectiveCtr.classList.add('perspective-ctr')
@@ -101,6 +104,7 @@
101104
thumb.style.right = '0';
102105
perspectiveCtr.insertBefore(thumb, perspectiveCtr.firstChild);
103106
scrollable.thumb = thumb;
107+
scrollable.perspectiveCtr = perspectiveCtr;
104108

105109
// We are on Safari, where we need to use the sticky trick!
106110
if (getComputedStyle(thumb).position === '-webkit-sticky') {

0 commit comments

Comments
 (0)