aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame-offset-forwarder.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-22 03:29:09 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-04-05 19:57:37 +0300
commit9fe1e38afb056164dbcc4369160bb9fd4790a2c0 (patch)
treeb7770f33bd2b0d883e4ae6737c5bf8fcc5011c7c /ext/fg/js/frame-offset-forwarder.js
parentd20ece9f074bb9d241a902f29344e5906e3c8210 (diff)
refactor
Diffstat (limited to 'ext/fg/js/frame-offset-forwarder.js')
-rw-r--r--ext/fg/js/frame-offset-forwarder.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js
index b3715c2a..09eb89a6 100644
--- a/ext/fg/js/frame-offset-forwarder.js
+++ b/ext/fg/js/frame-offset-forwarder.js
@@ -22,15 +22,23 @@
class FrameOffsetForwarder {
constructor() {
- this._forwardFrameOffset = window !== window.parent ?
+ this._started = false;
+
+ this._forwardFrameOffset = (
+ window !== window.parent ?
this._forwardFrameOffsetParent.bind(this) :
- this._forwardFrameOffsetOrigin.bind(this);
+ this._forwardFrameOffsetOrigin.bind(this)
+ );
this._windowMessageHandlers = new Map([
- ['getFrameOffset', ({offset, uniqueId}, e) => { return this._onGetFrameOffset(offset, uniqueId, e); }]
+ ['getFrameOffset', ({offset, uniqueId}, e) => this._onGetFrameOffset(offset, uniqueId, e)]
]);
+ }
+ start() {
+ if (this._started) { return; }
window.addEventListener('message', this.onMessage.bind(this), false);
+ this._started = true;
}
async applyOffset(x, y) {
@@ -44,7 +52,6 @@ class FrameOffsetForwarder {
chrome.runtime.onMessage.removeListener(runtimeMessageCallback);
callback();
frameOffsetResolve(params);
- return false;
}
};
chrome.runtime.onMessage.addListener(runtimeMessageCallback);