함수 공용화

This commit is contained in:
focp212@naver.com
2025-11-15 17:07:42 +09:00
parent 8857980e43
commit f2b093b848
19 changed files with 178 additions and 865 deletions

View File

@@ -1,4 +1,5 @@
import packageInfo from '../../../package.json';
import { useGroupDateOnStore, useGroupDateStore } from '../model/store';
export const IMAGE_ROOT = '/images';
export const RELEASE_VERSION = packageInfo.version;
@@ -32,4 +33,53 @@ export const GetListHeight = () => {
filterSectionHeight: filterSectionHeight,
listHeight: innerHeight - headerHeight - summarySectionHeight - filterSectionHeight
}
};
export const getMax = (data: Array<Record<string, any>>) => {
let maxItem = null;
if(data.length > 0){
let numberArr = data.map((
value: Record<string, any>,
index: number
) => {
return value.top;
});
let max = Math.max(...numberArr);
maxItem = data.filter((
value: Record<string, any>,
index: number
) => {
return value.top === max;
});
}
return maxItem? maxItem[0]: null;
};
export const setScrollAction = (
e: Event,
setGroupDate: (groupDate: string) => void,
setGroupDateOn: (groupDateOn: boolean) => void
) => {
let dateHeader = document.querySelectorAll('.date-header');
let posData: Array<Record<string, any>> = [];
dateHeader.forEach((value, index) => {
let date: string = value.innerHTML;
let top: number = value.getBoundingClientRect().top;
if(top < 10){
posData.push({
date: date,
top: top
});
}
});
let maxItem = getMax(posData);
if(maxItem){
setGroupDateOn(true);
setGroupDate(maxItem.date);
}
else{
setGroupDateOn(false);
setGroupDate('');
}
};