Comments (6)
Let's add the relevant values from that object to each of the dragged and receiver items in the drag events, as required rather than optional, for accuracy/convenience.
The dragged item will now have:
/** If being dragged or released, the relative offset of the drag point from the view */
dragOffset: Animated.ValueXY;
/** If being dragged, the relative offset of where the view was grabbed */
grabOffset: Position;
/** If being dragged, the relative offset/dimensions ratio of where the view was grabbed */
grabOffsetRatio: Position;
/** The position in screen coordinates of the dragged hover view (dragScreenPosition - grabOffset) */
hoverPosition: Animated.ValueXY;
Note that we omit dragScreenPosition
because it's already in the event data. Also I am uncertain on hoverPosition
, although I don't think it hurts to include it, and even if noHover
is enabled the value still exists unused.
We've already added the relevant values to the receiver data in #15
from react-native-drax.
I forgot that we can't access the viewState directly in the provider handler methods because we'll end up in a circular dependency. These methods only operate on the registry ref values and update state via dispatch, never depending on reading state. Still, the registry is able to calculate the updated values to dispatch to the updater, so it must be possible to have this information. It just might be awkward with the current logic organization.
from react-native-drax.
But I completely misremembered where this data lives. Yes, it's reflected in the viewState, but some or all of it is also in the registry and accessible (perhaps with some extra convenience methods).
from react-native-drax.
This is definitely a breaking change, as some field names will be changed for consistency as well.
from react-native-drax.
Why are we using Animated.ValueXY for these in the first place? It's harder to access the x/y values from those. We should only be using Animated values when we need to animate them. Currently the only one the library is animating is hoverPosition, which makes sense. (DraxList also uses its own animated shifts internally, but those don't matter for this.)
from react-native-drax.
Forgot to close this issue when it was addressed by PR #18 and released in 0.5.0
from react-native-drax.
Related Issues (20)
- Could not be used in expo go with android 12? HOT 2
- Cannot read properties of undefined (reading 'remove') HOT 2
- TypeError: undefined is not an object (evaluating 'listener.remove') HOT 1
- Drag starts on press instead of long press HOT 7
- RTL support? HOT 2
- Clipping leads to wrong sizes HOT 4
- SVG code HOT 2
- Conditional rendering of dragged item hover view when over specific receiver? (was: remove box logic) HOT 3
- Drag smooth on emulator but laggy on physical apk HOT 4
- Support for sorting horizontal wrapped lists?
- animate drop end similarly to snapback HOT 5
- Cannot drag out in web for expo sdk 49 HOT 5
- [iOS | Android] DragView does not return to the initial position after React Native 0.72.4 update HOT 2
- Expo Snack iOS Broken HOT 2
- Need Horizontal FlatList to hold items and still scroll for DraxViews/Recievers HOT 3
- Major improvements HOT 8
- react-native-drax doesnt work in react-native Modal component( HOT 1
- How to remove dragged view HOT 4
- DraxView all rendering issues HOT 2
- Ignoring gesture because view data was not found HOT 4
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-native-drax.