Skip to content

Commit

Permalink
different scroll container (target) than html, body
Browse files Browse the repository at this point in the history
I did not do extensive testings. I just fix this for my mdc theme with a different scroll while using the navigation drawer.
https://material.io/components/navigation-drawer

Usage example:

      $.scrollify({
        section : "article.post, .site-footer", // add .site-footer to reach bottom
        scrollSpeed: 200,
        setHeights: false,
        target:"#main-content"
      });
  • Loading branch information
marcoherzog committed Apr 24, 2021
1 parent ed2b109 commit 988501c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jquery.scrollify.js
Expand Up @@ -58,7 +58,6 @@ if touchScroll is false - update index
timeoutId2,
$window = $(window),
portHeight,
top = $window.scrollTop(),
scrollable = false,
locked = false,
scrolled = false,
Expand Down Expand Up @@ -92,9 +91,10 @@ if touchScroll is false - update index
after:function() {},
afterResize:function() {},
afterRender:function() {}
};
},
top = $(settings.target).scrollTop();
function getportHeight() {
return (window.innerHeight + settings.offset);
return ($(settings.target).innerHeight() + settings.offset);
}
function animateScroll(index,instant,callbacks,toTop) {
if(currentIndex===index) {
Expand Down Expand Up @@ -248,7 +248,7 @@ if touchScroll is false - update index
}, 200);
},
calculateNearest:function(instant,callbacks) {
top = $window.scrollTop();
top = $(settings.target).scrollTop();
var i =1,
max = heights.length,
closest = 0,
Expand Down Expand Up @@ -596,7 +596,7 @@ if touchScroll is false - update index

function sizePanels(keepPosition) {
if(keepPosition) {
top = $window.scrollTop();
top = $(settings.target).scrollTop();
}

var selector = settings.section;
Expand Down Expand Up @@ -642,7 +642,7 @@ if touchScroll is false - update index
}
});
if(keepPosition) {
$window.scrollTop(top);
$(settings.target).scrollTop(top);
}
}
function calculatePositions(scroll,firstLoad) {
Expand Down Expand Up @@ -696,7 +696,7 @@ if touchScroll is false - update index
if(!overflow[index]) {
return true;
}
top = $window.scrollTop();
top = $(settings.target).scrollTop();
if(top>parseInt(heights[index])) {
return false;
} else {
Expand All @@ -707,7 +707,7 @@ if touchScroll is false - update index
if(!overflow[index]) {
return true;
}
top = $window.scrollTop();
top = $(settings.target).scrollTop();
portHeight = getportHeight();

if(top<parseInt(heights[index])+(elements[index].outerHeight()-portHeight)-28) {
Expand Down

0 comments on commit 988501c

Please sign in to comment.