Skip to content

Instantly share code, notes, and snippets.

@enkows
enkows / getOffset.coffee
Created April 15, 2014 13:24
event.offsetX for Firefox
getOffset = (event) ->
target = event.target
# 计算当前触发元素到文档的距离
pageCoord =
X: 0
Y: 0
# 计算从当前触发元素到根节点为止,
# 各级 offsetParent 元素的 offsetLeft 或 offsetTop 值之和