pepjs-offset
Advanced tools
Comparing version 0.4.7 to 0.4.8
@@ -104,4 +104,31 @@ /*! | ||
e.isPrimary = inDict.isPrimary || false; | ||
e.offsetX = inDict.offsetX; | ||
e.offsetY = inDict.offsetY; | ||
var rect; | ||
function boundingClientRect() { | ||
if (rect) { | ||
return rect; | ||
} | ||
return (rect = inDict.target.getBoundingClientRect()); | ||
} | ||
if (inDict.offsetX === undefined) { | ||
Object.defineProperty(e, 'offsetX', { | ||
get: function() { | ||
return e.clientX - boundingClientRect().left - inDict.target.clientLeft; | ||
} | ||
}); | ||
} else { | ||
e.offsetX = inDict.offsetX; | ||
} | ||
if (inDict.offsetY === undefined) { | ||
Object.defineProperty(e, 'offsetY', { | ||
get: function() { | ||
return e.clientY - boundingClientRect().top - inDict.target.clientTop; | ||
} | ||
}); | ||
} else { | ||
e.offsetY = inDict.offsetY; | ||
} | ||
return e; | ||
@@ -108,0 +135,0 @@ } |
{ | ||
"name": "pepjs-offset", | ||
"version": "0.4.7", | ||
"version": "0.4.8", | ||
"main": "dist/pep.js", | ||
@@ -5,0 +5,0 @@ "description": "Polyfill of the PointerEvents W3C spec", |
@@ -93,4 +93,31 @@ /** | ||
e.isPrimary = inDict.isPrimary || false; | ||
e.offsetX = inDict.offsetX; | ||
e.offsetY = inDict.offsetY; | ||
var rect; | ||
function boundingClientRect() { | ||
if (rect) { | ||
return rect; | ||
} | ||
return (rect = inDict.target.getBoundingClientRect()); | ||
} | ||
if (inDict.offsetX === undefined) { | ||
Object.defineProperty(e, 'offsetX', { | ||
get: function() { | ||
return e.clientX - boundingClientRect().left - inDict.target.clientLeft; | ||
} | ||
}); | ||
} else { | ||
e.offsetX = inDict.offsetX; | ||
} | ||
if (inDict.offsetY === undefined) { | ||
Object.defineProperty(e, 'offsetY', { | ||
get: function() { | ||
return e.clientY - boundingClientRect().top - inDict.target.clientTop; | ||
} | ||
}); | ||
} else { | ||
e.offsetY = inDict.offsetY; | ||
} | ||
return e; | ||
@@ -97,0 +124,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122840
3135