Skip to content

Commit

Permalink
mode/hint: Set style.right for :left hints
Browse files Browse the repository at this point in the history
Calculate and set style.right instead of setting style.left +
style.transform (for :left hints).

Limit style.left/right in both directions: Not less than 0, not to close
to the window border.
  • Loading branch information
MaxGyver83 committed Nov 14, 2023
1 parent 756bdd7 commit 7b1a359
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions source/mode/hint.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,34 @@ A positive value shifts to the bottom.")
(:left padding-left)
(:right (- padding-right))
(otherwise 0)))
(absolute-x-position (+ (ps:@ window page-x-offset)
relative-x-position
padding-x-adjustment
user-x-offset))
(inner-width (ps:@ window inner-width))
(max-x-position (- inner-width 25))
(element (ps:chain document (create-element "span"))))
(setf (ps:@ element class-name) "nyxt-hint"
(ps:@ element style position) "absolute"
(ps:@ element style left) (+ (ps:max (+ (ps:@ window page-x-offset)
relative-x-position
padding-x-adjustment
user-x-offset)
0)
"px")
(ps:@ element style left) (unless (eq user-x-alignment :left)
(+ (ps:min
max-x-position
(ps:max
0
absolute-x-position))
"px"))
(ps:@ element style right) (when (eq user-x-alignment :left)
(+ (ps:min
max-x-position
(ps:max
0
(- inner-width absolute-x-position)))
"px"))
(ps:@ element style top) (+ (ps:max (+ (ps:@ window page-y-offset)
(ps:@ rect top)
user-y-offset)
0)
"px")
(ps:@ element style transform) (when (eq user-x-alignment :left)
"translate(-100%, 0)")
(ps:@ element id) (+ "nyxt-hint-" hint)
(ps:@ element text-content) hint)
element))
Expand Down

0 comments on commit 7b1a359

Please sign in to comment.