Skip to content

fix: merge and simplify redundant 'findSlot' func#119

Open
Marco-Pagani wants to merge 1 commit into
fuxingloh:mainfrom
Marco-Pagani:main
Open

fix: merge and simplify redundant 'findSlot' func#119
Marco-Pagani wants to merge 1 commit into
fuxingloh:mainfrom
Marco-Pagani:main

Conversation

@Marco-Pagani

Copy link
Copy Markdown

While working with this package I found that findNextSlot and findPrevSlot do exactly the same thing, with the logical operations written slightly differently. Both functions boil down to a single condition:

for (let i = 0; i < children.length; i++) {
  const rect = children[i].getBoundingClientRect()

  if ( x <= rect.right) return children[i]
  else continue
}

I combined these functions into one new function, and I also rewrote it using Array.find instead of a for loop to make it more concise.

This doesn't change any behavior of the package, just makes the code cleaner and easier to maintain. I hope this helps!

flip logic

match logic to previous behavior
@netlify

netlify Bot commented Aug 27, 2022

Copy link
Copy Markdown

👷 Deploy Preview for vue-horizontal processing.

Name Link
🔨 Latest commit 1dc60dc
🔍 Latest deploy log https://app.netlify.com/sites/vue-horizontal/deploys/630a2a014e51630008909a16

@Marco-Pagani

Copy link
Copy Markdown
Author

I'll try to take a look at the test failures sometime soon, I didn't see that happening on my local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant