From 04bcea6a575477ed7e7eaade8a62bb24e3613646 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Mon, 12 Jul 2021 12:37:48 +0300 Subject: [PATCH] remove commented-out stuff --- src/js/components/MessageFeed.js | 82 -------------------------------- 1 file changed, 82 deletions(-) diff --git a/src/js/components/MessageFeed.js b/src/js/components/MessageFeed.js index de6fd97c..a7dde46f 100644 --- a/src/js/components/MessageFeed.js +++ b/src/js/components/MessageFeed.js @@ -83,88 +83,6 @@ class MessageFeed extends Component { `; } - /* - adjustPaddings(isScrollDown) { - const container = document.getElementById("container"); - const currentPaddingTop = getNumFromStyle(container.style.paddingTop); - const currentPaddingBottom = getNumFromStyle(container.style.paddingBottom); - const remPaddingsVal = 198 * (size / 2); // TODO: calculate actual element heights - if (isScrollDown) { - container.style.paddingTop = currentPaddingTop + remPaddingsVal + "px"; - container.style.paddingBottom = currentPaddingBottom === 0 ? "0px" : currentPaddingBottom - remPaddingsVal + "px"; - } else { - container.style.paddingBottom = currentPaddingBottom + remPaddingsVal + "px"; - if (currentPaddingTop === 0) { - $(window).scrollTop($('#post0').offset().top + remPaddingsVal); - } else { - container.style.paddingTop = currentPaddingTop - remPaddingsVal + "px"; - } - } - } - - topSentCallback(entry) { - const container = document.getElementById("container"); - - const currentY = entry.boundingClientRect.top; - const currentRatio = entry.intersectionRatio; - const isIntersecting = entry.isIntersecting; - - // conditional check for Scrolling up - if ( - currentY > topSentinelPreviousY && - isIntersecting && - currentRatio >= topSentinelPreviousRatio && - scroller.center !== previousUpIndex && // stop if no new results were received - scroller.opts.stickTo !== 'top' - ) { - previousUpIndex = scroller.center; - adjustPaddings(false); - scroller.up(size / 2); - } - topSentinelPreviousY = currentY; - topSentinelPreviousRatio = currentRatio; - } - - botSentCallback(entry) { - const currentY = entry.boundingClientRect.top; - const currentRatio = entry.intersectionRatio; - const isIntersecting = entry.isIntersecting; - - // conditional check for Scrolling down - if ( - currentY < bottomSentinelPreviousY && - currentRatio > bottomSentinelPreviousRatio && - isIntersecting && - scroller.center !== previousDownIndex && // stop if no new results were received - scroller.opts.stickTo !== 'bottom' - ) { - previousDownIndex = scroller.center; - adjustPaddings(true); - scroller.down(size / 2); - } - bottomSentinelPreviousY = currentY; - bottomSentinelPreviousRatio = currentRatio; - } - - initIntersectionObserver() { - const options = { - //rootMargin: '190px', - } - - const callback = entries => { - entries.forEach(entry => { - if (entry.target.id === 'post0') { - topSentCallback(entry); - } else if (entry.target.id === `post${size - 1}`) { - botSentCallback(entry); - } - }); - } - - var observer = new IntersectionObserver(callback, options); // TODO: It's possible to quickly scroll past the sentinels without them firing. Top and bottom sentinels should extend to page top & bottom? - observer.observe(document.querySelector("#post0")); - observer.observe(document.querySelector(`#post${size - 1}`)); - } */ } export default MessageFeed;