mirror of
https://github.com/pomber/git-history.git
synced 2024-09-11 14:35:57 +03:00
Fix scroll navigation
This commit is contained in:
parent
f11002e599
commit
8ca216e4f2
@ -105,5 +105,11 @@ export function getChanges(lines) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (currentChange) {
|
||||
currentChange.end = i - 1;
|
||||
changes.push(currentChange);
|
||||
currentChange = null;
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import React from "react";
|
||||
import useChildren from "./use-virtual-children";
|
||||
import "./scroller.css";
|
||||
import useSpring from "./use-spring";
|
||||
import { nextIndex, prevIndex, closestIndex, getScrollTop } from "./utils";
|
||||
import { nextIndex, prevIndex, getScrollTop } from "./utils";
|
||||
|
||||
const initialState = {
|
||||
snap: false,
|
||||
@ -23,6 +23,8 @@ export default function Scroller({
|
||||
|
||||
const reducer = (prevState, action) => {
|
||||
switch (action.type) {
|
||||
case "unsnap":
|
||||
return !prevState.snap ? prevState : { ...prevState, snap: false };
|
||||
case "change-area":
|
||||
if (snapAreas.length === 0) {
|
||||
return prevState;
|
||||
@ -129,6 +131,12 @@ export default function Scroller({
|
||||
// });
|
||||
// }, [snapAreas]);
|
||||
|
||||
React.useEffect(() => {
|
||||
dispatch({
|
||||
type: "unsnap"
|
||||
});
|
||||
}, [snapAreas]);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
if (snap) {
|
||||
ref.current.scrollTop = top;
|
||||
|
Loading…
Reference in New Issue
Block a user