diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-09 13:39:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-09 13:39:08 -0700 |
commit | f0d162c73462784e1b0f6dcb3f040f12103cfe5c (patch) | |
tree | cbde8aab1bcd2b92f028c98d2ec486e39679f490 /src | |
parent | 92fe68caa71f9a78b2767f5b618206eb1495aac8 (diff) |
proxy boundingClientRect
Diffstat (limited to 'src')
-rw-r--r-- | src/proxyClient.js | 1 | ||||
-rw-r--r-- | src/proxyWorker.js | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/proxyClient.js b/src/proxyClient.js index 5bfa4ddf..04f7ed11 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -26,6 +26,7 @@ worker.onmessage = function(event) { Module.canvas.width = data.width; Module.canvas.height = data.height; Module.canvasData = Module.ctx.getImageData(0, 0, data.width, data.height); + postMessage({ target: 'canvas', boundingClientRect: Module.canvas.getBoundingClientRect() }); break; } case 'render': { diff --git a/src/proxyWorker.js b/src/proxyWorker.js index 8d641b0d..29b2528d 100644 --- a/src/proxyWorker.js +++ b/src/proxyWorker.js @@ -62,6 +62,17 @@ document.createElement = function(what) { } }; }; + canvas.boundingClientRect = {}; + canvas.getBoundingClientRect = function() { + return { + width: canvas.boundingClientRect.width, + height: canvas.boundingClientRect.height, + top: canvas.boundingClientRect.top, + left: canvas.boundingClientRect.left, + bottom: canvas.boundingClientRect.bottom, + right: canvas.boundingClientRect.right + }; + }; return canvas; } default: throw 'document.createElement ' + what; @@ -119,7 +130,11 @@ onmessage = function(message) { break; } case 'canvas': { - Module.canvas.fireEvent(message.data.event); + if (message.data.event) { + Module.canvas.fireEvent(message.data.event); + } else if (message.data.boundingClientRect) { + Module.canvas.boundingClientRect = message.data.boundingClientRect; + } else throw 'ey?'; break; } default: throw 'wha? ' + message.data.target; |