Skip to content

Commit

Permalink
lock wrapper scroll when popover is shown.
Browse files Browse the repository at this point in the history
  • Loading branch information
aferditamuriqi committed Mar 1, 2022
1 parent 93dfa03 commit 6a68c6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/modules/linefocus/LineFocusModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,31 +161,31 @@ export default class LineFocusModule implements ReaderModule {

private keydown(event: KeyboardEvent | MouseEvent | TrackEvent): void {
if (event instanceof KeyboardEvent && this.isActive) {
const key = event.key;
switch (key) {
case "ArrowUp":
const key = event.key;
switch (key) {
case "ArrowUp":
event.stopPropagation();
break;
case "ArrowDown":
break;
case "ArrowDown":
event.stopPropagation();
break;
}
break;
}
}
}

private keyup(event: KeyboardEvent | MouseEvent | TrackEvent): void {
if (event instanceof KeyboardEvent && this.isActive) {
const key = event.key;
switch (key) {
case "ArrowUp":
this.lineUp();
break;
case "ArrowDown":
this.lineDown();
break;
}
const key = event.key;
switch (key) {
case "ArrowUp":
this.lineUp();
break;
case "ArrowDown":
this.lineDown();
break;
}
}
}

handleResize() {
if (this.isActive) {
Expand Down
10 changes: 8 additions & 2 deletions src/modules/search/Popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export class Popup {
if (footnote) {
footnote.parentElement?.removeChild(footnote);
}
const wrapper = HTMLUtilities.findRequiredElement(
document,
"#iframe-wrapper"
);
wrapper.style.overflow = "auto";
}

async showPopover(link: HTMLLIElement, event: MouseEvent | TouchEvent) {
Expand Down Expand Up @@ -97,6 +102,7 @@ export class Popup {
document,
"#iframe-wrapper"
);
wrapper.style.overflow = "hidden";
d2popover.style.top = wrapper.scrollTop + "px";
d2popover.style.height = wrapper.clientHeight * 0.9 + "px";

Expand All @@ -122,11 +128,11 @@ export class Popup {
if (!win) {
return;
}
let self = this;
win.onclick = function (ev) {
if (event.target !== ev.target) {
if (d2popover.parentElement) {
d2popover.style.display = "none";
d2popover.parentElement.removeChild(d2popover);
self.hidePopover();
if (win) {
win.onclick = null;
}
Expand Down

0 comments on commit 6a68c6b

Please sign in to comment.