본문 바로가기

web/javascript57

화면 스크롤 로드 체크 - new IntersectionObserver const io = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { var sectionName = $(entry.target).attr("class"); var subGubun = sectionName.split(" ")[1]; //console.log( "active.class", subGubun ); $(entry.target).addClass('active').trigger("activeClass"); onSearch(subGubun); } }); }); document.querySelectorAll("section").forEach((item) => { io.. 2023. 5. 30.
Axios in Typescript 원본 : https://bobbyhadz.com/blog/typescript-http-request-axios 2022. 9. 4.
Fetch in TypeScript 원본 : https://www.delftstack.com/howto/typescript/typescript-fetch/ Fetch in TypeScript The fetch is a globally available native browser function that can be used to fetch resource over an HTTP connection. In TypeScript, we can use the fetch function to consume typed response data. www.delftstack.com // Todo type interface interface Todo { userId: number; id: number; title: string; completed: boo.. 2022. 9. 4.
화면 활성화 비활성화 active deactive , visibilitychange document.addEventListener('visibilitychange', function() { if (document.hidden) { if ( handleInterval > 0 ) clearInterval(handleInterval); } else { if ( handleInterval > 0 ) clearInterval(handleInterval); console.log("============== ACTIVE ============="); handleInterval = setInterval(()=>{ },intervalTime); } }, false); 2022. 8. 19.
antd useRef current.focus // const inputRef = useRef({}); // const inputRef = useRef({}); type RefType = { [key : string] : HTMLElement} const inputRef = useRef({}); const register = ((elem: any) => { const key = elem?.input?.id || elem?.props?.id || elem?.resizableTextArea?.props?.id; console.log('register', elem, key); return inputRef.current[key] = elem; }); const msgAlert = (msg: string, id: string) => { // a.. 2022. 6. 14.
typescript onchange moment const handleChange = ({ target }: { target: HTMLInputElement | { name: string, value: moment.Moment | string | null } }) => { const { name, value } = target; // if (target instanceof HTMLInputElement) { // } else { // } // moment.isMoment(value); console.log(name, value); setData({ ...data, [name]: value }); }; 2022. 6. 12.