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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Marco-Pagani
Copy link

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
Copy link

netlify bot commented Aug 27, 2022

👷 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
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