Window: screenX property
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
* Some parts of this feature may have varying levels of support.
Window.screenX ì½ê¸° ì ì© ìì±ì
ì¬ì©ìì ë¸ë¼ì°ì ë·°í¬í¸ì ì¼ìª½ í
ë리ìì íë©´ ì¼í¸ê¹ì§ì ìí 거리를
CSS í½ì
ë¨ìë¡ ë°íí©ëë¤.
ì°¸ê³ :>screenX ì ë³ì¹ì ìµì ë¸ë¼ì°ì ì
Window.screenLeftë¡ êµ¬íëììµëë¤.
ì´ë ìë IE ë¸ë¼ì°ì ìë§ ì§ìì´ ëìì¼ë ì¸ì§ë ëë¶ì ì´ë ê³³ììë ìê°ëììµëë¤.
ê°
ë¸ë¼ì°ì ë·°í¬í¸ì ì¼ìª½ ê°ì¥ì리ìì íë©´ì ì¼ìª½ ê°ì¥ì리ê¹ì§ì CSS í½ì ë¨ìì ëì¼í ì«ìì ëë¤.
ìì
screenleft-screentop (source code) ìì ììë ìíì¼ë¡ ê·¸ë ¤ì§ ìºë²ì¤ë¥¼ íì¸í ì ììµëë¤. ì´ ìì ììë Window.screenLeft/Window.screenTop ì ëíì¬ Window.requestAnimationFrame() 를 ì¬ì©íì¬ ì°½ ìì¹ê° ë°ëì´ë ì§ìì ì¼ë¡ íë©´ ë´ìì 물리ì ì¼ë¡ ëì¼í ìì¹ì ìíì 그립ëë¤.
initialLeft = window.screenLeft + canvasElem.offsetLeft;
initialTop = window.screenTop + canvasElem.offsetTop;
function positionElem() {
let newLeft = window.screenLeft + canvasElem.offsetLeft;
let newTop = window.screenTop + canvasElem.offsetTop;
let leftUpdate = initialLeft - newLeft;
let topUpdate = initialTop - newTop;
ctx.fillStyle = "rgb(0 0 0)";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "rgb(0 0 255)";
ctx.beginPath();
ctx.arc(
leftUpdate + width / 2,
topUpdate + height / 2 + 35,
50,
degToRad(0),
degToRad(360),
false,
);
ctx.fill();
pElem.textContent = `Window.screenLeft: ${window.screenLeft}, Window.screenTop: ${window.screenTop}`;
window.requestAnimationFrame(positionElem);
}
window.requestAnimationFrame(positionElem);
ì´ë screenX/screenY ì ìì í ëì¼í ëìì í©ëë¤.
ëí ì½ëììë screenLeft ì ì§ìíëì§, ë§ì¼ ì§ìíì§ ìì¼ë©´
screenLeft/screenTop ì í´ë¦¬íì screenX/screenY ë¡ ì¬ì©í ì ìëë¡
íì§í기 ìí´ ì¤ëí«ì´ ì¶ê°ëììµëë¤.
if (!window.screenLeft) {
window.screenLeft = window.screenX;
window.screenTop = window.screenY;
}
ëª ì¸ì
| Specification |
|---|
| CSSOM View Module > # dom-window-screenx > |