Added 2 new options: direction constrains and sorting by distance#29
Conversation
index.html
Outdated
There was a problem hiding this comment.
Missing a </code> here, which causes wonky styling for the rest of the page.
|
Documentation and tests included, nice work! I'm loving the simplicity of the With the |
|
It doesn't have to be, i just didn't have a lot of time to play with it and make it work with the multiple elements functionality. Unfortunately I can't promise I can get more time to spend on this, as I'm on a very tight schedule on a client project. Your plugin was the fastest way to get the functionality I was looking for, it just missed a couple of features :) The If I could provide one feedback is that your code is too "imperative". It's essentially one big function, where it could be split into smaller parts that are easier to reason with. For example, you have a lot of comments in your code where you are specifying what you are doing below. You could have instead extracted that code into it's own function, that can be tested separately and it's clear to see what its dependencies are through the arguments it gets passed. |
|
No worries. I'm happy to merge this one in as-is and tweak it slightly, using your tests as a reference. I completely agree about the code. I wrote this plugin 5 years ago and its contents have not greatly changed since then, but my coding knowledge/style has. At some point I'll get around to a full rewrite to make the code easier to understand, and also to make it a standalone library that doesn't need jQuery but can still work with it. I'm tracking that in issue #27 if you have any other suggestions. |
Added 2 new options: direction constrains and sorting by distance
This PR solves #20 and overlaps with PR #22 (but offers more functionality)
Added a new option called
directionConstraintsthat takes an array of directions and filters the results to those that only appear in all the directions specified. This option will only work for Single Element Operations and gets ignored for anything else. Available directions:left,right,top,bottomAdded another new option called
sortthat takes a sorting order,nearestorfurthest, and sorts the results based on their distance instead of the order they appear on the DOM.P.s: Nice testing setup. Was easy to hook into and add more tests