mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Fixes brush strokes not compositing correct on initial load
This commit is contained in:
parent
9291fde960
commit
6a32adb7ed
@ -1,4 +1,4 @@
|
|||||||
import { useLayoutEffect } from 'react';
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
||||||
import { RootState, useAppSelector } from '../../../../app/store';
|
import { RootState, useAppSelector } from '../../../../app/store';
|
||||||
import { maskLayerRef } from '../InpaintingCanvas';
|
import { maskLayerRef } from '../InpaintingCanvas';
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ const Cacher = () => {
|
|||||||
isDrawing,
|
isDrawing,
|
||||||
} = useAppSelector((state: RootState) => state.inpainting);
|
} = useAppSelector((state: RootState) => state.inpainting);
|
||||||
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!maskLayerRef.current) return;
|
if (!maskLayerRef.current) return;
|
||||||
maskLayerRef.current.cache({
|
maskLayerRef.current.cache({
|
||||||
@ -66,7 +67,22 @@ const Cacher = () => {
|
|||||||
isDrawing,
|
isDrawing,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
/**
|
||||||
|
* Hack to cache the mask layer after the canvas is ready.
|
||||||
|
*/
|
||||||
|
useEffect(() => {
|
||||||
|
const intervalId = window.setTimeout(() => {
|
||||||
|
if (!maskLayerRef.current) return;
|
||||||
|
maskLayerRef.current.cache({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
});
|
||||||
|
}, 0)
|
||||||
|
|
||||||
|
return () => { window.clearTimeout(intervalId); }
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Cacher;
|
export default Cacher;
|
||||||
|
Loading…
Reference in New Issue
Block a user