Fixed auto-scroll into view of currently selected tab.

This commit is contained in:
Maxim Stewart 2019-02-10 04:15:12 -06:00
parent 7feec057a5
commit 5afaf1d6a0
4 changed files with 18 additions and 15 deletions

View File

@ -4,9 +4,9 @@ Search Firefox tabs and get a list or automatic direct to the searched tab.
# Download
https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/
# Version: 1.2.9
# Version: 1.3.0
<ul>
<li>Fixed window selection issue.</li>
<li>Fixed auto-scroll into view of currently selected tab.</li>
</ul>
***Note:

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Tab Search and Manage",
"version": "1.2.9",
"version": "1.3.0",
"description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.",
"applications": {

View File

@ -4,7 +4,7 @@ document.getElementById("searchBar").onkeypress = function () {
// Set click events for tab blocks
document.addEventListener("click", (e) => {
var target = (!e.target.className.includes("pTagTitleText")) ? e.target : e.target.parentElement;
var target = (!e.target.className.includes("pTagTitleText")) ? e.target : e.target.parentElement;
var targetID = target.id;
var parentElm = target.parentElement;
var id = 0;
@ -18,9 +18,7 @@ document.addEventListener("click", (e) => {
} else if (targetID == "goBottom") {
window.scrollTo(0, document.body.scrollHeight);
} else if (targetID == "goToTab") {
// Go to selected and 100px up
oldElm.scrollIntoView();
window.scrollBy(0, -100);
scrollToView(200);
} else if (targetID == "newTab") {
createTab();
} else if (targetID == "hideTgglBttn") {
@ -34,7 +32,7 @@ document.addEventListener("click", (e) => {
}
});
function closeBttnAction(var target, var targetID, var parentElm, var id) {
function closeBttnAction(target, targetID, parentElm, id) {
if (parentElm == oldElm) {
var index = Array.from(parentElm.parentElement.children).indexOf(parentElm);
(index - 1 < 0) ? index++ : index-- ; // Check what index to chose
@ -51,7 +49,7 @@ function closeBttnAction(var target, var targetID, var parentElm, var id) {
parentElm.parentElement.removeChild(parentElm);
}
function setNewTabAction(var target, var targetID, var parentElm, var id) {
function setNewTabAction(target, targetID, parentElm, id) {
id = parseInt(target.getAttribute("tabID"));
tabsAction.get(id).then((tab) => {
browser.windows.update(tab.windowId, {focused: true});
@ -61,7 +59,7 @@ function setNewTabAction(var target, var targetID, var parentElm, var id) {
setOldElm(target);
}
function hideSelectedTabAction(var target, var targetID, var parentElm, var id) {
function hideSelectedTabAction(target, targetID, parentElm, id) {
id = parseInt(parentElm.getAttribute("tabID"));
if (id != oldElm.getAttribute("tabID")) {
@ -77,7 +75,7 @@ function hideSelectedTabAction(var target, var targetID, var parentElm, var id)
}
}
function setSearchModeAction(var target, var targetID, var parentElm, var id) {
function setSearchModeAction(target, targetID, parentElm, id) {
var currentMode = target.getAttribute("searchwindowsmode");
if (currentMode == "true") {
// In generateview
@ -94,3 +92,11 @@ function setOldElm(target) {
oldElm = target;
target.setAttribute("class", "block block-focused");
}
function scrollToView(time) {
setTimeout(function () {
// Go to selected and 100px up
oldElm.scrollIntoView();
window.scrollBy(0, -100);
}, time);
}

View File

@ -16,7 +16,6 @@ function logTabs(tabs) {
windowIndex = 0;
tabsAction.query({currentWindow: true, active: true}).then((tab) => {
console.log(tab);
focusedWinID = tab[0].windowId;
}, focusedWinID).then(() => {
for (let tab of tabs) {
@ -44,9 +43,7 @@ function logTabs(tabs) {
});
newWinId = undefined;
// Set poped-out-window position and 100px up from selected elm
oldElm.scrollIntoView();
window.scrollBy(0, -100);
scrollToView(800);
}
function createContainer(tab) {