Comments (7)
I kind of got it working and here's a brief demo, is it what you expected?
from react-anything-sortable.
It's currently unsupported but I think it's achievable.
from react-anything-sortable.
Hmm, I can think of a few different instances where you'd want to specify the "allowed" positions that an element should be able to take (eg. only every even position, or every 5th position, or beginning or end, only next to some other type of element, etc). Which methods would one have to modify to support something like this?
I'm assuming the right methods would be swapArrayItemPosition
(to control how / which items were swapped) and either calculateNewIndex
or getIndexByOffset
? I'm think the easiest way to support (just my use case - every other item) would be to mod 2 any newindex that would be assigned to the placeholder (I already have it so that when the user drops the item, it re-renders with the proper elements in the right spot).
from react-anything-sortable.
If we were to add this new feature, I'd like it to be adoptable by anyone other than only your case.
The solution I'm thinking of is providing an option like sortTarget
, and only children's className match sortTarget will be sortable, anything else remains untouched.
I'll let you know if it works out, also a PR is warmly welcomed!
from react-anything-sortable.
Yes that's exactly what I was looking for! Much appreciated!
from react-anything-sortable.
Cool, I'll add according tests and release a new version.
from react-anything-sortable.
released 1.4.5
from react-anything-sortable.
Related Issues (20)
- Class 'ui-sortable-item' not being added when using <SortableContainer> HOT 6
- How to run 'modern usage'? HOT 2
- `SortableItem.className` is discarded
- List inside list HOT 1
- Get `SortableContainer` usage straight HOT 12
- RTL support? HOT 1
- Bug when re-rendering occurs while mouse is pressed HOT 3
- Previous sortedArray HOT 1
- Unknown prop sortHandle on <div> tag HOT 1
- Recursive lists HOT 1
- "Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead."
- "React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead." HOT 4
- sorting is broken in ie11 && FF when scrolled down HOT 3
- index.js has a global reference to window, causing server side rendering to crash HOT 2
- Sort stop working when combining map and fixed items
- Get container position on mouse down HOT 1
- Firefox + IE11 when scrolling is still broken HOT 2
- Grid option HOT 1
- Not working on Mobile browser properly.. HOT 2
- Drag on Image or link will hold on the sortableItem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-anything-sortable.