이정민

gif 퍼센트 표시

...@@ -17,6 +17,7 @@ const GifEditor = ({ previewURL }) => { ...@@ -17,6 +17,7 @@ const GifEditor = ({ previewURL }) => {
17 17
18 const [download, setDownload] = useState(null); 18 const [download, setDownload] = useState(null);
19 const [blob, setBlob] = useState(null); 19 const [blob, setBlob] = useState(null);
20 + const [percent, setPercent] = useState(0);
20 21
21 const [isMakeStarted, setIsMakeStarted] = useState(false); 22 const [isMakeStarted, setIsMakeStarted] = useState(false);
22 const [isUploadLoading, setIsUploadLoading] = useState(false); 23 const [isUploadLoading, setIsUploadLoading] = useState(false);
...@@ -51,8 +52,11 @@ const GifEditor = ({ previewURL }) => { ...@@ -51,8 +52,11 @@ const GifEditor = ({ previewURL }) => {
51 const gifGenerator = new window.GifGenerator( 52 const gifGenerator = new window.GifGenerator(
52 imageEditor._graphics.getCanvas() 53 imageEditor._graphics.getCanvas()
53 ); 54 );
55 + gifGenerator.on("progress", (p: number) => {
56 + setPercent(Math.round(p * 100));
57 + });
54 gifGenerator.make().then( 58 gifGenerator.make().then(
55 - (blob) => { 59 + (blob: Blob) => {
56 setBlob(blob); 60 setBlob(blob);
57 setDownload(window.URL.createObjectURL(blob)); 61 setDownload(window.URL.createObjectURL(blob));
58 }, 62 },
...@@ -80,7 +84,7 @@ const GifEditor = ({ previewURL }) => { ...@@ -80,7 +84,7 @@ const GifEditor = ({ previewURL }) => {
80 {((isMakeStarted && !download) || isUploadLoading) && ( 84 {((isMakeStarted && !download) || isUploadLoading) && (
81 <> 85 <>
82 <div className="background" /> 86 <div className="background" />
83 - <div className="download">loading...</div> 87 + <div className="download">loading... {percent}%</div>
84 </> 88 </>
85 )} 89 )}
86 {!isUploadLoading && viewLink && ( 90 {!isUploadLoading && viewLink && (
......