1seok2

refactor: remove useless codes

1 export const togglePageLoader = (type: boolean): void => { 1 export const togglePageLoader = (type: boolean): void => {
2 - const $loader: HTMLDivElement | null = document.querySelector(".page-loader"); 2 + const $loader = document.querySelector(".page-loader") as HTMLDivElement;
3 - if ($loader) { 3 +
4 - if (type) { 4 + if (type === true) {
5 - $loader.style.display = "block"; 5 + $loader.style.display = "block";
6 - $loader.style.zIndex = "1"; 6 + $loader.style.zIndex = "1";
7 - } else { 7 + } else {
8 - $loader.style.display = "none"; 8 + $loader.style.display = "none";
9 - $loader.style.zIndex = "-1"; 9 + $loader.style.zIndex = "-1";
10 - }
11 } 10 }
12 }; 11 };
13 12
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
4 * @description : 페이지 이동 효과 주는 함수 4 * @description : 페이지 이동 효과 주는 함수
5 **/ 5 **/
6 6
7 +import { getElement } from "./functions";
8 +
7 let $div: HTMLDivElement; 9 let $div: HTMLDivElement;
8 10
9 const pageTransitionClassList = [ 11 const pageTransitionClassList = [
...@@ -12,8 +14,7 @@ const pageTransitionClassList = [ ...@@ -12,8 +14,7 @@ const pageTransitionClassList = [
12 "transition-2", 14 "transition-2",
13 ]; 15 ];
14 16
15 -const getDivs = (): HTMLDivElement => 17 +const getDivs = () => getElement(".page-transition") as HTMLDivElement;
16 - document.querySelector(".page-transition") as HTMLDivElement;
17 18
18 const turnOnAndOff = (idx: number) => { 19 const turnOnAndOff = (idx: number) => {
19 $div.classList.toggle(pageTransitionClassList[idx]); 20 $div.classList.toggle(pageTransitionClassList[idx]);
...@@ -30,7 +31,7 @@ const turnOnAndOff = (idx: number) => { ...@@ -30,7 +31,7 @@ const turnOnAndOff = (idx: number) => {
30 31
31 export const initialTrantition = () => { 32 export const initialTrantition = () => {
32 $div = $div || getDivs(); 33 $div = $div || getDivs();
33 - $div && turnOnAndOff(0); 34 + turnOnAndOff(0);
34 }; 35 };
35 36
36 export const randomTransition = () => { 37 export const randomTransition = () => {
...@@ -39,7 +40,7 @@ export const randomTransition = () => { ...@@ -39,7 +40,7 @@ export const randomTransition = () => {
39 Math.random() * (pageTransitionClassList.length - 1) + 1 40 Math.random() * (pageTransitionClassList.length - 1) + 1
40 ); 41 );
41 42
42 - $div && turnOnAndOff(randomIndex); 43 + turnOnAndOff(randomIndex);
43 }; 44 };
44 45
45 export default function animatePage() { 46 export default function animatePage() {
......