ํ์๋ค์ด ๊ณตํต์ผ๋ก ์งํํ ์ฝ๋๋ฅผ ๋ค์ ๋ด๋ ค๋ฐ์์ ์๋ก ์์ ์ ์์ํ๊ธฐ๋ก ํ๊ธฐ ๋๋ฌธ์ ๊ธฐ์กด ์ฝ๋๋ฅผ ์ด๋ฆฌ๊ณ ์ถ๋ค๋ฉด ์๋ก์ด ๋ธ๋์น๋ฅผ ํ์ ์งํํ๊ธฐ๋ก ํ๋ค.
์ด์ ์ ์ ๋ง ์ค๋ซ๋์ ๋ฒ๋ฒ
๋๊ธฐ ๋๋ฌธ์ ์ผ๋จ ์ฝ๋๋ฅผ ์ง๊ณ ์๊ธฐ ์ ์ git์ pushํด๋๊ณ ์๊ธฐ๋ก ํ๋ค. ๊ทผ๋ฐ...๋ ์๋๋ค?ใ
ใ
ใ
ใ
ใ
๊ฒฐ๊ตญ ํด๊ฒฐํ๊ธด ํ๋ค. ์ด๋ค ๋ฌธ์ ์๋๋ฉด...
local branch์ remote branch๋ ์ด๋ฆ์ด ๊ฐ์์ผ ํ๋ค. ๋~!
์ด์ byte์๋ฅผ ์ธ๋ ๋ฐฉ๋ฒ์ ์๊ฐํ์๋๋ฐ ์ด๊ฒ๋ ์๋ฒฝํ ์ ๋ต์ ์๋ ๊ฒ ๊ฐ์์ react์์ overflow๋ฅผ ๊ฐ์งํ๋ ๋ฒ์ ๋ํด ์จ์นญํ๋ค.
offsetWidth๋ ํ๋ฉด์ ๋๋๋ง ๋ width๊ฐ์ ์๋ ค์ฃผ๊ณ
scrollWidth๋ ์๋ฆฐ ๋ถ๋ถ์ ํฌํจํ ์์์ ๋๋น๋ฅผ ์๋ ค์ค๋จ๋ค.
๊ทธ๋์
const checkOverflow = (str) => {
return (str.offsetWidth < str.scrollWidth)
}
const handleTodoItemMouseEnter = () => {
console.log(checkOverflow(text))
}
-๋ฅผ ํ๋๋...
์ ์๋จนํใ
๊ณฐ๊ณฐํ ์๊ฐํด๋ณด๋ text๊ฐ pํ๊ทธ๋ฅผ ๊ฐ๋ฆฌํค๋ ๊ฒ ์๋๋ผ ๊ทธ๋ฅ ๋์ด์ค๋ text๋ฐ์ดํฐ๋ฅผ ๊ฐ๋ฆฌํจ๋ค๋ ๊ฑธ ๊นจ๋ซ๊ณ ๋ค๋ฆ๊ฒ react์์ pํ๊ทธ๋ฅผ ๊ฐ๋ฆฌํค๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์ฐพ์๋ดค๋๋ฐ ์ด๊ฒ ๋ฐ๋ก useRef์์...
const handleTodoItemMouseEnter = () => { console.log(ref.current.scrollWidth) }
return (
<p ref={ref}>{text}</p>
)
์ด๋ ๊ฒ ํ๋๊น
์ ๋์จ๋ค. ์ธ๊ณ ์ถ๋ค ํ...ใ
ใ
const handleTodoItemMouseEnter = () => {
if (itemTextRef.current.scrollWidth > itemTextRef.current.offsetWidth)
setHoverItem(true)
}
์ด๋ ๊ฒ ํ๋๊น ๋ง์ค์ ๋ item๋ค๋ง tooltip์ด ๋ด๋ค!
๋ด์ฉ์ ๊ธธ๊ฒํ๋๋ text๊ฒน์นจ๋ฌธ์ ๊ฐ ๋ํ๋ฌ๋ค. position:absolute๋ฅผ ํ๋๋ฐ ์ ๊ฒน์นจ๋ฌธ์ ๊ฐ ๋์ค์ง?
z-index๊ฐ์ ์ฃผ๋๊น ๋งค์ฐ ๊ฐ๋จํ ํด๊ฒฐ๋์๋ค. ๊น์...
position:absolute๋ฅผ ํ๋ฉด ์ ์ผ ์๋ก ์ฌ๋ผ๊ฐ ์ค ์์๋ค. ์จ์นญ ํ position์ ์ด ์์์ z-index๊ฐ์ด ๋จนํ๋ค๋ ๊ฑธ ์์๋ค.