Initial commit 2.0 beta 0
This commit is contained in:
+15
-15
@@ -10,10 +10,10 @@
|
||||
css transforms without perspective projection)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
;(function () {
|
||||
'use strict'
|
||||
|
||||
var I = (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix() : new WebKitCSSMatrix()
|
||||
var I = typeof WebKitCSSMatrix == 'undefined' ? new DOMMatrix() : new WebKitCSSMatrix()
|
||||
|
||||
function Point(x, y, z) {
|
||||
this.x = x
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
function createMatrix(transform) {
|
||||
try {
|
||||
return (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix(transform) : new WebKitCSSMatrix(transform)
|
||||
} catch(e) {
|
||||
return typeof WebKitCSSMatrix == 'undefined' ? new DOMMatrix(transform) : new WebKitCSSMatrix(transform)
|
||||
} catch (e) {
|
||||
console.warn(transform)
|
||||
console.warn(e.toString())
|
||||
return I
|
||||
@@ -54,8 +54,9 @@
|
||||
var left = +Infinity
|
||||
var top = +Infinity
|
||||
while (--i >= 0) {
|
||||
var p = new Point(i === 0 || i === 1 ? 0 : w, i === 0 || i === 3 ? 0 : h,
|
||||
0).transformBy(transformationMatrix)
|
||||
var p = new Point(i === 0 || i === 1 ? 0 : w, i === 0 || i === 3 ? 0 : h, 0).transformBy(
|
||||
transformationMatrix
|
||||
)
|
||||
if (p.x < left) {
|
||||
left = p.x
|
||||
}
|
||||
@@ -64,20 +65,19 @@
|
||||
}
|
||||
}
|
||||
var rect = element.getBoundingClientRect()
|
||||
transformationMatrix = I.translate(window.pageXOffset + rect.left - left,
|
||||
window.pageYOffset + rect.top - top, 0)
|
||||
.multiply(transformationMatrix)
|
||||
transformationMatrix = I.translate(
|
||||
window.pageXOffset + rect.left - left,
|
||||
window.pageYOffset + rect.top - top,
|
||||
0
|
||||
).multiply(transformationMatrix)
|
||||
return transformationMatrix
|
||||
}
|
||||
|
||||
window.convertPointFromPageToNode = function (element, pageX, pageY) {
|
||||
return new Point(pageX, pageY, 0).transformBy(
|
||||
getTransformationMatrix(element).inverse())
|
||||
return new Point(pageX, pageY, 0).transformBy(getTransformationMatrix(element).inverse())
|
||||
}
|
||||
|
||||
window.convertPointFromNodeToPage = function (element, offsetX, offsetY) {
|
||||
return new Point(offsetX, offsetY, 0).transformBy(
|
||||
getTransformationMatrix(element))
|
||||
return new Point(offsetX, offsetY, 0).transformBy(getTransformationMatrix(element))
|
||||
}
|
||||
|
||||
}());
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user