Skip to content

Commit

Permalink
Bugfix: fast clicking will break accordion and shows multiple opened …
Browse files Browse the repository at this point in the history
…directories

Signed-off-by: Philipp <p.koenig@blockbyte.de>
  • Loading branch information
Philipp committed Oct 31, 2018
1 parent 5aaa548 commit 5f158fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"url": "https://github.com/Kiuryy/Bookmark_Sidebar"
},
"scripts": {
"init": "npm install --only=dev && npm run release",
"release": "ncu -a --packageFile package.json && npm update && node build/run.js",
"init": "npm install --only=dev",
"release": "ncu -a --packageFile package.json && npm install --only=dev && node build/run.js",
"scss": "node-sass --source-map true -o src/css src/scss"
},
"devDependencies": {
Expand All @@ -27,7 +27,7 @@
"npm-check-updates": "^2.14.2",
"read-file": "^0.2.0",
"request": "^2.88.0",
"terser": "^3.10.4",
"terser": "^3.10.8",
"zip-dir": "^1.0.2"
}
}
34 changes: 24 additions & 10 deletions src/js/helper/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

let restoreOpenStateRunning = 0;
let sort = null;
let dirOpenDuration = 0;

/**
*
Expand All @@ -31,6 +32,9 @@
});
});

const dirOpenDurationRaw = ext.helper.model.getData("b/dirOpenDuration");
dirOpenDuration = +dirOpenDurationRaw * 1000;

this.updateBookmarkBox();
};

Expand Down Expand Up @@ -201,12 +205,24 @@
if (close) { // close children
expandCollapseDir(elm, childrenList, false, instant).then(preResolve);
} else { // open children
if (ext.helper.model.getData("b/dirAccordion")) { // close all directories except the current one and its parents
if (ext.helper.model.getData("b/dirAccordion") && cache === true) { // close all directories except the current one and its parents
const visibleBox = ext.helper.search.isResultsVisible() ? "search" : "all";

ext.elm.bookmarkBox[visibleBox].find("a." + $.cl.sidebar.dirOpened).forEach((dir) => {
if ($(dir).next("ul").find("a[" + $.attr.id + "='" + dirId + "']").length() === 0) {
this.toggleBookmarkDir($(dir), instant, false);
$([
ext.elm.bookmarkBox[visibleBox].find("a." + $.cl.sidebar.dirOpened), // opened directory
ext.elm.bookmarkBox[visibleBox].find("a." + $.cl.sidebar.dirAnimated + ":not(" + $.cl.sidebar.dirOpened + ")") // not yet opened directory
]).forEach((dir) => {
if (dir !== elm[0] && $(dir).next("ul").find("a[" + $.attr.id + "='" + dirId + "']").length() === 0) {
let delay = 0;

if ($(dir).hasClass($.cl.sidebar.dirAnimated)) { // another directory is being opened already -> wait until the animation is finished to prevent visual bugs
delay = dirOpenDuration;
}

$.delay(instant ? 0 : delay).then(() => {
$(dir).addClass($.cl.sidebar.dirOpened); // add class to properly close it
this.toggleBookmarkDir($(dir), instant, false).then(preResolve);
});
}
});
}
Expand Down Expand Up @@ -410,14 +426,14 @@
this.addBookmarkDir = (bookmarks, list, asTree = true, sorting = true) => {
let hasEntries = false;
const showSeparators = asTree && sort.name === "custom" && list.prev("a").length() > 0; // only show separators for custom sorting and in tree view
const config = ext.helper.model.getData(["a/directoryArrows", "a/showBookmarkIcons", "a/showDirectoryIcons", "b/dirOpenDuration", "u/showHidden"]);
const config = ext.helper.model.getData(["a/directoryArrows", "a/showBookmarkIcons", "a/showDirectoryIcons", "u/showHidden"]);

if (list.parents("li").length() === 0) {
if (ext.helper.search.isResultsVisible() === false) { // don't show in search results
updatePinnedEntries(config);
}
} else {
list.css("transition", "height " + config.dirOpenDuration + "s");
list.css("transition", "height " + dirOpenDuration + "ms");
}

let bookmarkCounter = 0;
Expand Down Expand Up @@ -713,7 +729,7 @@
list.css("height", list[0].scrollHeight + "px");

if (open === false) { // parameter false -> close list
$.delay(0).then(() => {
$.delay(50).then(() => {
list.css("height", 0);
});
}
Expand All @@ -733,9 +749,7 @@
}
}

const dirOpenDurationRaw = ext.helper.model.getData("b/dirOpenDuration");

$.delay(instant ? 0 : (+dirOpenDurationRaw * 1000)).then(() => { // unset changes in css, so opening of children in child list works properly
$.delay(instant ? 20 : dirOpenDuration).then(() => { // unset changes in css, so opening of children in child list works properly
if (open === false) {
elm.removeClass($.cl.sidebar.dirOpened);
} else {
Expand Down

0 comments on commit 5f158fc

Please sign in to comment.