Skip to content

Commit

Permalink
0.9.57
Browse files Browse the repository at this point in the history
enable auto detect of modal elements only after clicking on some element and disable it on starting to scroll
  • Loading branch information
brookhong committed Jan 5, 2020
1 parent a140195 commit 77f21db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions content_scripts/hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ function createHints() {
} else {
self.mouseoutLastElement();
dispatchMouseEvent(element, behaviours.mouseEvents, shiftKey);
Normal.turnOnDOMObserver();
lastMouseTarget = element;
}
}
Expand Down
33 changes: 19 additions & 14 deletions content_scripts/normal.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,6 @@ function createNormal() {
event.sk_stopPropagation = true;
} else if (event.sk_keyName.length) {
Mode.handleMapKey.call(self, event);
if (!DOMObserver.isConnected) {
getDocumentBody.then(function(body) {
DOMObserver.observe(body, { childList: true, subtree:true });
DOMObserver.isConnected = true;
});
}
}
});
self.addEventListener('blur', function(event) {
Expand Down Expand Up @@ -734,6 +728,7 @@ function createNormal() {
default:
break;
}
self.turnOffDOMObserver();
};

self.refreshScrollableElements = function () {
Expand Down Expand Up @@ -1211,16 +1206,29 @@ function createNormal() {
}
}

self.turnOnDOMObserver = function() {
if (!DOMObserver.isConnected) {
getDocumentBody.then(function(body) {
DOMObserver.observe(body, { childList: true, subtree:true });
DOMObserver.isConnected = true;
});
}
};

self.turnOffDOMObserver = function() {
if (DOMObserver.isConnected) {
DOMObserver.disconnect();
DOMObserver.isConnected = false;
}
};

var _disabled = null;
self.disable = function() {
if (!_disabled) {
_disabled = createDisabled();
_disabled.enter(0, true);
}
if (DOMObserver.isConnected) {
DOMObserver.disconnect();
DOMObserver.isConnected = false;
}
self.turnOffDOMObserver();
document.removeEventListener("mouseup", _onMouseUp);
};

Expand All @@ -1234,10 +1242,7 @@ function createNormal() {
self.enable();

self.onExit = function() {
if (DOMObserver.isConnected) {
DOMObserver.disconnect();
DOMObserver.isConnected = false;
}
self.turnOffDOMObserver();
_nodesHasSKScroll.forEach(function(n) {
delete n.skScrollBy;
delete n.smoothScrollBy;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Surfingkeys",
"short_name": "Rich shortcuts in vim spirit for productivity with keyboard.",
"version": "0.9.56",
"version": "0.9.57",
"description": "Rich shortcuts to click links/switch tabs/scroll pages or capture full page, use Chrome like vim for productivity.",
"icons": {
"16": "icons/16.png",
Expand Down

0 comments on commit 77f21db

Please sign in to comment.