Skip to content

Commit

Permalink
improve LinkHints.click: add .loop and fix flash rect in focus mode
Browse files Browse the repository at this point in the history
for #1129
  • Loading branch information
gdh1995 committed May 22, 2024
1 parent 2c52d89 commit 72423bf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions content/link_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,15 @@ const doPostAction = (): Rect | null => {
} else if (forHover_) {
(HintMode.HOVER + 1 === HintMode.UNHOVER ? HintMode.HOVER & 1 ? mode1_ & 1 : !(mode1_ & 1)
: HintMode.HOVER < HintMode.UNHOVER ? mode1_ < HintMode.HOVER + 1 : mode1_ > HintMode.HOVER - 1)
? hoverEl() : retPromise = catchAsyncErrorSilently(wrap_enable_bubbles(hintOptions, unhover_async<1>, [clickEl]))
? hoverEl() : retPromise = catchAsyncErrorSilently(wrap_enable_bubbles(hintOptions, unhover_async<1>
, [realClickEl || clickEl]))
} else if (mode1_ < HintMode.FOCUS + 1) {
view_(clickEl)
setNewScrolling(clickEl)
focus_(clickEl)
set_cachedScrollable(currentScrolling)
showUrlIfNeeded()
removeFlash || showRect && flash_(clickEl)
removeFlash || showRect && flash_(clickEl, tag === "a" || hint.r ? rect as never : null)
showRect = 0
} else if (mode1_ < HintMode.max_media + 1) {
downloadOrOpenMedia()
Expand Down
2 changes: 1 addition & 1 deletion content/link_hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export const findAnElement_ = (options: OptionsToFindElement, count: number, als
compareDocumentPosition(midEl, cur as Element) & kNode.DOCUMENT_POSITION_FOLLOWING // midEl < cur
? low = mid + 1 : high = mid - 1
}
return low < -matchIndex ? end : low + matchIndex
return exOpts.loop ? (low + matchIndex) % end : low < -matchIndex ? end : low + matchIndex
}
let isSel: boolean | BOOL | undefined
let matches: (Hint | Hint0)[] | undefined, oneMatch: Hint | Hint0 | undefined, matchIndex: number
Expand Down
1 change: 1 addition & 0 deletions typings/messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ interface OptionsToFindElement extends CSSOptions, OtherFilterOptions {
search?: "view" | "doc" | "document"
offset?: 0 | "cur" | "current" | "end" | "last"
index?: "count" | number
loop?: boolean | BOOL
}
targetOptions?: object
}
Expand Down

0 comments on commit 72423bf

Please sign in to comment.