Skip to content

Commit

Permalink
correct paper tab scroll event timer
Browse files Browse the repository at this point in the history
  • Loading branch information
joshslee committed Dec 15, 2020
1 parent ee73b40 commit 8214217
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions components/PaperTabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const PaperTabBar = (props) => {
const store = useStore();
const [selectedTab, setSelectedTab] = useState("main");
const [tabs, setTabs] = useState(props.activeTabs.map(formatTabs));
const [scrollEvent, setScrollEvent] = useState(null);

const { scrollView } = props;
var timer;

useEffect(() => {
window.addEventListener("scroll", scrollListener);
Expand All @@ -28,8 +29,13 @@ const PaperTabBar = (props) => {
}, [scrollListener]);

useEffect(() => {
clearTimer();
startTimer();
clearTimeout(scrollEvent);

setScrollEvent(
setTimeout(() => {
trackEvent("scroll", selectedTab);
}, VIEW_TIMER)
);
}, [selectedTab]);

useEffect(() => {
Expand All @@ -56,15 +62,9 @@ const PaperTabBar = (props) => {
}
}, [props.showAllSections]);

const startTimer = () => {
timer = setTimeout(() => {
trackEvent("scroll", selectedTab);
}, VIEW_TIMER);
};
const startTimer = () => {};

const clearTimer = () => {
clearTimeout(timer);
};
const clearTimer = () => {};

const getCoords = (elem) => {
// crossbrowser version
Expand Down

0 comments on commit 8214217

Please sign in to comment.