Skip to content

Commit

Permalink
Bugfix: Click determination after changing sidebar width
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp <p.koenig@blockbyte.de>
  • Loading branch information
Philipp committed Sep 23, 2018
1 parent 64bfb31 commit 03ae2de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
checkLicenseKey(opts.licenseKey).then((response) => {
if (response.valid === true) { // valid license key -> reinitialize sidebar
this.helper.model.setLicenseKey(opts.licenseKey).then(() => {
this.reinitialize({type: "premiumActivated"});
return this.reinitialize({type: "premiumActivated"});
}).then(() => {
resolve({success: true});
});
Expand Down
10 changes: 6 additions & 4 deletions src/js/helper/sidebarEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,20 @@
ext.helper.contextmenu.close();
ext.helper.tooltip.close();
ext.helper.toggle.addSidebarHoverClass();

ext.elm.widthDrag.data("dragInfo", {start: e.clientX, width: ext.elm.sidebar.realWidth()});
ext.elm.widthDrag.addClass($.cl.drag.isDragged);
});

ext.elm.iframeBody.on("mousemove", (e) => {
if (ext.elm.widthDrag.hasClass($.cl.drag.isDragged) && e.which === 1) {
e.preventDefault();
e.stopPropagation();

let dragInfo = ext.elm.widthDrag.data("dragInfo");
if (!dragInfo) {
dragInfo = {start: e.clientX, width: ext.elm.sidebar.realWidth()};
ext.elm.widthDrag.data("dragInfo", dragInfo);
}

let diff = e.clientX - dragInfo.start;

if (sidebarPos === "right") {
Expand Down Expand Up @@ -393,11 +397,9 @@
if (message.type === "Removed" || (message.type === "Created" && isRestoring === true)) { // removed or created from undo -> prevent reload when it was performed on this browser tab
Object.values(ext.elm.bookmarkBox).some((box) => {
if (box.hasClass($.cl.active)) {

if (box.find("a." + $.cl.sidebar.restored).length() > 0 || box.find("span." + $.cl.sidebar.removeMask).length() > 0) { // prevent reloading the sidebar on the tab where the entry got removed or restored
performReload = false;
}

return true;
}
});
Expand Down
16 changes: 12 additions & 4 deletions src/js/helper/toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let preventWindowed = null;
let openDelay = 0;
let indicatorWidth = null;
let sidebarWidth = null;
let inPixelToleranceTime = null;
let mouseNotTopLeft = false;
let timeout = {};
Expand Down Expand Up @@ -58,8 +59,13 @@
ext.elm.iframe.attr($.attr.position, sidebarPos);
ext.elm.sidebar.attr($.attr.position, sidebarPos);

if (data.styles && data.styles.indicatorWidth) {
indicatorWidth = parseInt(data.styles.indicatorWidth);
if (data.styles) {
if (data.styles.indicatorWidth) {
indicatorWidth = parseInt(data.styles.indicatorWidth);
}
if (data.styles.sidebarWidth) {
sidebarWidth = parseInt(data.styles.sidebarWidth);
}
}

if (data.showIndicator && data.openAction !== "icon" && data.openAction !== "mousemove") { // show indicator
Expand Down Expand Up @@ -250,16 +256,18 @@
ext.elm.iframe.find("body").on("click", (e) => { // click outside the sidebar -> close
if (e.clientX) {
let clientX = e.clientX;
let curSidebarWidth = ext.elm.sidebar.realWidth();

if (sidebarPos === "right") {
if (sidebarHasMask()) {
clientX = window.innerWidth - clientX + ext.elm.sidebar.realWidth() - 1;
clientX = window.innerWidth - clientX + (sidebarWidth || curSidebarWidth) - 1;
} else {
clientX = ext.elm.iframe.realWidth() - clientX;
}
}

if (
clientX > ext.elm.sidebar.realWidth() &&
clientX > curSidebarWidth &&
ext.elm.iframe.hasClass($.cl.page.visible) &&
ext.elm.widthDrag.hasClass($.cl.drag.isDragged) === false
) {
Expand Down

0 comments on commit 03ae2de

Please sign in to comment.