layerY
Summary
Returns the horizontal coordinate of the event relative to the current layer. layerY is a non-standards property of the MouseEvent object.
Property of dom/MouseEventdom/MouseEvent
Syntax
var result = element.layerY;
element.layerY = value;
Return Value
Returns an object of type NumberNumber
The scaled value of the mouse X and Y positions relative to the positioned elements’ client position. This may be an integer or double value depending on the viewport scale value.
Examples
Microsoft added the layerY property to the MouseEvent in IE9 for Interoperability purposes, but recommends using the offsetY property instead. The example below uses feature testing to detect IE9 and higher emulation modes and uses the event.offsetX value. For webkit and gecko and IE8 and lower emulation modes, the event.layerY or the event.offsetY values are used instead.
if(document.documentMode&&document.documentMode>=9){
form.layerXCoords.value = evt.offsetX;
form.layerYCoords.value = evt.offsetY;
}
else
{
form.layerXCoords.value = (evt.layerX)?evt.layerX:evt.offsetX;
form.layerYCoords.value = (evt.layerY)?evt.layerY:evt.offsetY;
}
Usage
Determining the relative mouse position on scrollable web pages.
Notes
Remarks
A positioned element is an element whose position property is set to relative
, absolute
or fixed
. For more information about element positioning, see About Element Positioning. Note This property is provided for cross-browser compatibility. Use y instead.
Syntax
Standards information
There are no standards that apply here.
Attributions
Mozilla Developer Network : [MDM event.layery Article]
Microsoft Developer Network: [event.layery Article]
Portions of this content come from HTML5Rocks! [Using Multiple HTML5 canvases as layers article]