Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
adnan-td committed Jul 3, 2023
1 parent fb4ccdc commit 323532b
Show file tree
Hide file tree
Showing 3 changed files with 947 additions and 965 deletions.
6 changes: 1 addition & 5 deletions src/context/mouse.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ interface ContextInterface {
removeLayer: () => void;
}

const defaultMouseProperties: MouseSettings = {
radius: 12 / 2,
};

export const MousePropertiesContext = createContext<ContextInterface>(null);

export const FollowerProvider = ({ children }: Props) => {
const layerStack = useStack(defaultMouseProperties);
const layerStack = useStack();
const addLayer = (layerOptions: MouseSettings) => {
layerStack.push(layerOptions);
};
Expand Down
11 changes: 7 additions & 4 deletions src/util/stack_hook.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { useEffect, useState } from 'react';
import type { MouseSettings } from '../types/index.js';

export const useStack = (
defaultMouseProperties: MouseSettings,
): {
const defaultMouseProperties: MouseSettings = {
radius: 12 / 2,
};

export const useStack = (): {
stack: MouseSettings[];
push: (options: MouseSettings) => void;
pop: () => MouseSettings | undefined;
Expand All @@ -18,6 +20,7 @@ export const useStack = (
const push = (options: MouseSettings): void => {
setStack((prevStack) => {
const item: MouseSettings = {
...defaultMouseProperties,
...prevStack[prevStack.length - 1],
...options,
};
Expand All @@ -38,7 +41,7 @@ export const useStack = (
if (stack.length > 0) {
return stack[stack.length - 1];
}
return undefined;
return defaultMouseProperties;
};

const isEmpty = (): boolean => {
Expand Down
Loading

0 comments on commit 323532b

Please sign in to comment.