adjusted scroll down detection zone

This commit is contained in:
Maxim Stewart 2020-10-31 00:30:34 -05:00
parent efe171582d
commit cb6a1cb3ed
4 changed files with 39 additions and 8 deletions

View File

@ -4,8 +4,8 @@ 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.11 # Version: 1.3.13
* Css change for control 1 * adjusted scroll down detection zone
***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.11", "version": "1.3.13",
"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

@ -1,5 +1,6 @@
var count = 2; toMoveID = 0, newIndex = 0;; let count = 2; toMoveID = 0, newIndex = 0;;
var insert = ""; let insert = "";
let isDragging = false;
var drake = dragula({ var drake = dragula({
direction: 'horizontal', // X axis is considered when determining where an element would be dropped direction: 'horizontal', // X axis is considered when determining where an element would be dropped
@ -9,7 +10,8 @@ var drake = dragula({
removeOnSpill: false, // spilling will `.remove` the element, if this is true removeOnSpill: false, // spilling will `.remove` the element, if this is true
ignoreInputTextSelection: true // allows users to select input text, see details below ignoreInputTextSelection: true // allows users to select input text, see details below
}).on('drag', function (el) { }).on('drag', function (el) {
toMoveID = parseInt(el.getAttribute("tabID")); isDragging = true;
toMoveID = parseInt(el.getAttribute("tabID"));
el.className = el.className.replace('ex-moved', ''); el.className = el.className.replace('ex-moved', '');
}).on('drop', function (el, container) { }).on('drop', function (el, container) {
var subCont = document.getElementById("listZone"); var subCont = document.getElementById("listZone");
@ -21,6 +23,7 @@ var drake = dragula({
} }
} }
isDragging = false;
tabsAction.move(toMoveID, {index: newIndex}).then(); tabsAction.move(toMoveID, {index: newIndex}).then();
el.className += ' ex-moved'; el.className += ' ex-moved';
}).on('over', function (el, container) { }).on('over', function (el, container) {
@ -29,5 +32,20 @@ var drake = dragula({
container.className = container.className.replace('ex-over', ''); container.className = container.className.replace('ex-over', '');
}); });
drake.on("cancel", (el, container, source) => {
isDragging = false;
el.scrollIntoView();
let i = 0;
while( (el = el.previousSibling) != null ) {
i++;
}
if (i < (container.children.length - 6)) {
container.scrollBy(0, -100); // Go up 100px
}
});
// Connect to pre created containers // Connect to pre created containers
drake.containers.push(document.querySelector('#listZone')); drake.containers.push(document.querySelector('#listZone'));

View File

@ -6,6 +6,19 @@ window.onload = async () => {
getTabs(); getTabs();
} }
document.addEventListener("mousemove", (e) => {
if (isDragging) {
const elm = document.getElementById("listZone");
if (e.pageY > 520) {
console.log("scrolling down...");
elm.scrollBy(0, 50); // Scroll 50px downwards
} else if (e.pageY < 100) {
console.log("scrolling up...");
elm.scrollBy(0, -50); // Scroll 50px upwards
}
}
});
// Set click events for tab blocks // Set click events for tab blocks
document.addEventListener("click", (e) => { document.addEventListener("click", (e) => {
@ -158,8 +171,8 @@ function setOldElm(target) {
function scrollToView(time = 400) { function scrollToView(time = 400) {
setTimeout(function () { setTimeout(function () {
// Go to selected and 100px up const elm = document.getElementById("listZone");
oldElm.scrollIntoView(); oldElm.scrollIntoView();
window.scrollBy(0, -100); elm.scrollBy(0, -100); // Scroll 100px upwards
}, time); }, time);
} }