Skip to content

Commit

Permalink
fix: current index doesn't reset when modify data length
Browse files Browse the repository at this point in the history
fix #163
  • Loading branch information
dohooo committed May 1, 2022
1 parent 650f405 commit 99f44bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useCommonVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ICommonVariables {
export function useCommonVariables(
props: TInitializeCarouselProps<any>
): ICommonVariables {
const { vertical, height, width, data, defaultIndex } = props;
const { vertical, height, width, data, defaultIndex, rawData } = props;
const size = vertical ? height : width;
const validLength = data.length - 1;
const defaultHandlerOffsetX = -Math.abs(defaultIndex * size);
Expand All @@ -23,7 +23,7 @@ export function useCommonVariables(
* #163 add deps with rawData.
**/
handlerOffsetX.value = defaultHandlerOffsetX;
}, [vertical, handlerOffsetX, defaultHandlerOffsetX]);
}, [vertical, handlerOffsetX, defaultHandlerOffsetX, rawData]);

return {
size,
Expand Down

0 comments on commit 99f44bc

Please sign in to comment.