2020-01-03
정리
: Javascript30을 공부한 내용 기록
transform의 사용 방법 숙지.
style 입력하기.
secondHand.style.height = '3px';
hourHand.style.height = '8px';
const changeDegrees = (target) => (degree) =>
(target.style.transform = `rotate(${degree}deg)`);
Date를 호출하는 방법.
const now = new Date();
const seconds = now.getSeconds();
const secondsDegrees = (seconds / 60) * 360 + 90;
changeDegrees(secondHand)(secondsDegrees);
const mins = now.getMinutes();
const minsDegrees = (mins / 60) * 360 + (seconds / 60) * 6 + 90;
changeDegrees(minsHand)(minsDegrees);
const hour = now.getHours();
const hourDegrees = (hour / 12) * 360 + (mins / 60) * 30 + 90;
changeDegrees(hourHand)(hourDegrees);
👋