Changed scroll logic and timings

This commit is contained in:
Maxim Stewart 2020-03-27 14:34:04 -05:00
parent 3edbf0ab70
commit 640b9acdb4
4 changed files with 17 additions and 10 deletions

View File

@ -4,8 +4,10 @@ Search Firefox tabs and get a list or automatic direct to the searched tab.
# Download # Download
https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/ https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/
# Version: 1.3.6 # Version: 1.3.7
* Added create new window button * Fixed scroll to top
* Fixed scroll to bottom
* Improved scroll to current tab time.
***Note: ***Note:

View File

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

View File

@ -2,6 +2,11 @@ document.getElementById("searchBar").onkeyup = function () {
searchTabs(); searchTabs();
} }
window.onload = async () => {
getTabs();
}
// Set click events for tab blocks // Set click events for tab blocks
document.addEventListener("click", (e) => { 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;
@ -16,11 +21,13 @@ document.addEventListener("click", (e) => {
} else if (targetID == "iconElm") { } else if (targetID == "iconElm") {
setNewTabAction(target, targetID, parentElm, id); setNewTabAction(target, targetID, parentElm, id);
} else if (targetID == "goTop") { } else if (targetID == "goTop") {
window.scrollTo(0,0); const elm = document.getElementById("listZone");
elm.scrollTo(0,0);
} else if (targetID == "goBottom") { } else if (targetID == "goBottom") {
window.scrollTo(0, document.body.scrollHeight); const elm = document.getElementById("listZone");
elm.scrollTo(0,elm.scrollHeight);
} else if (targetID == "goToTab") { } else if (targetID == "goToTab") {
scrollToView(200); scrollToView();
} else if (targetID == "newTab") { } else if (targetID == "newTab") {
createTab(); createTab();
} else if (targetID == "newWin") { } else if (targetID == "newWin") {
@ -103,7 +110,7 @@ function setOldElm(target) {
target.setAttribute("class", "block block-focused"); target.setAttribute("class", "block block-focused");
} }
function scrollToView(time) { function scrollToView(time = 200) {
setTimeout(function () { setTimeout(function () {
// Go to selected and 100px up // Go to selected and 100px up
oldElm.scrollIntoView(); oldElm.scrollIntoView();

View File

@ -44,7 +44,7 @@ function logTabs(tabs) {
}); });
newWinId = undefined; newWinId = undefined;
scrollToView(800); scrollToView();
} }
function createContainer(tab) { function createContainer(tab) {
@ -170,5 +170,3 @@ function clearNodes(targetNode) {
function resetWinIndex() { function resetWinIndex() {
windowIndex = 0; windowIndex = 0;
} }
getTabs();