Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing classes to anchor docs and fixed anchor position caching #4371

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/anchor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ export default function (Alpine) {

if (! reference) throw 'Alpine: no element provided to x-anchor...'

let previousValue
let compute = () => {
let previousValue

computePosition(reference, el, {
placement,
middleware: [flip(), shift({padding: 5}), offset(offsetValue)],
Expand All @@ -35,9 +34,8 @@ export default function (Alpine) {
if (JSON.stringify({ x, y }) !== previousValue) {
el._x_anchor.x = x
el._x_anchor.y = y
previousValue = JSON.stringify({ x, y })
}

previousValue = JSON.stringify({ x, y })
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/en/plugins/anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Because `x-anchor` accepts a reference to any DOM element, you can use utilities
</div>


<div x-show="open" x-anchor="document.querySelector('.trigger')">
<div x-show="open" x-anchor="document.querySelector('.trigger')" class="bg-white rounded p-4 border shadow z-10">
Dropdown content
</div>
</div>
Expand Down
Loading