Skip to content

Commit

Permalink
feat(swap)!: put cssSelector arg before direction
Browse files Browse the repository at this point in the history
This models the actual scroll/show modifier closer.
  • Loading branch information
angelofallars committed Nov 25, 2023
1 parent f8167a3 commit 3fabed8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ func (s SwapStrategy) Scroll(direction Direction) SwapStrategy {

// ScrollOn changes the scrolling behavior based on the given direction and CSS selector.
//
// ScrollOn([htmx.Top], cssSelector) scrolls to the top of the element found by the selector.
// ScrollOn(cssSelector, [htmx.Top]) scrolls to the top of the element found by the selector.
//
// ScrollOn([htmx.Bottom], cssSelector) scrolls to the bottom of the element found by the selector.
// ScrollOn(cssSelector, [htmx.Bottom]) scrolls to the bottom of the element found by the selector.
//
// Adds the 'scroll:<cssSelector>:<direction ("top" | "bottom")>' modifier.
//
// For more info, see https://htmx.org/attributes/hx-swap/
func (s SwapStrategy) ScrollOn(direction Direction, cssSelector string) SwapStrategy {
func (s SwapStrategy) ScrollOn(cssSelector string, direction Direction) SwapStrategy {
v := s.cutPrefix("scroll")
mod := "scroll:" + cssSelector + ":" + direction.dirString()
return SwapStrategy(join(v, mod))
Expand Down Expand Up @@ -242,14 +242,14 @@ func (s SwapStrategy) Show(direction Direction) SwapStrategy {

// ShowOn changes the show behavior based on the given direction and CSS selector.
//
// ShowOn([htmx.Top], cssSelector) shows the top of the element found by the selector.
// ShowOn(cssSelector, [htmx.Top]) shows the top of the element found by the selector.
//
// ShowOn([htmx.Bottom], cssSelector) shows the bottom of the element found by the selector.
// ShowOn(cssSelector, [htmx.Bottom]) shows the bottom of the element found by the selector.
//
// Adds the 'show:<cssSelector>:<direction ("top" | "bottom")>' modifier.
//
// For more info, see https://htmx.org/attributes/hx-swap/
func (s SwapStrategy) ShowOn(direction Direction, cssSelector string) SwapStrategy {
func (s SwapStrategy) ShowOn(cssSelector string, direction Direction) SwapStrategy {
v := s.cutPrefix("show")
mod := "show:" + cssSelector + ":" + direction.dirString()
return SwapStrategy(join(v, mod))
Expand Down

0 comments on commit 3fabed8

Please sign in to comment.