Skip to content

Commit

Permalink
fix: correct position logic in isElementBeforeOrAfter function
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-ema committed Nov 19, 2024
1 parent 02bdfe6 commit 4c14922
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,12 @@ export function isSlide(elem) {
*/
export function isElementBeforeOrAfter(element, sibling) {
if (element === sibling) return "same"
if (element.parentElement !== sibling.parentElement) return -1;

const position = element.compareDocumentPosition(sibling);
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
if (position & Node.DOCUMENT_POSITION_FOLLOWING ) {
return "before";
} else if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
} else if (position & Node.DOCUMENT_POSITION_PRECEDING) {
return "after";
}

Expand Down

0 comments on commit 4c14922

Please sign in to comment.