GithubHelp home page GithubHelp logo

Comments (11)

DanielMartini avatar DanielMartini commented on June 28, 2024 13

Idk if it has changed but I achieved it just with:

constructor(props) { super(props); this.state = { scrollEnabled: true, }

then in the SortableGrid:

onDragRelease = {() => {this.setState({scrollEnabled: true})}} onDragStart = {() => {this.setState({scrollEnabled: false})}}

and finally attach the state to the ScrollView

<ScrollView scrollEnabled={this.state.scrollEnabled}>

from react-native-sortable-grid.

QShengW avatar QShengW commented on June 28, 2024 3

The latest solution combined with @indivisable 's answers.
<ScrollView
ref='myScrollView'
...
onDrag(bool) {
this.refs.myScrollView.setNativeProps({ scrollEnabled: bool });
}
onDragStart={() => { this.onDrag(false) }}
onDragRelease={(itemOrder) => { this.onDrag(true) }}

from react-native-sortable-grid.

geminiyellow avatar geminiyellow commented on June 28, 2024 1

should merge this into README, this lib need more good document.

from react-native-sortable-grid.

QShengW avatar QShengW commented on June 28, 2024 1

@DanielMartini This is not applicable. If there is a delete function, it can not be dragged after deleting.

from react-native-sortable-grid.

coolsou avatar coolsou commented on June 28, 2024

thanks for sharing

from react-native-sortable-grid.

sam-tse avatar sam-tse commented on June 28, 2024

The solution provided by @DanielMartini works as well. Thanks!

from react-native-sortable-grid.

eduardojunio avatar eduardojunio commented on June 28, 2024

@sam-tse are you sure? I tried here but when I try to drag the block it doesn't move, and when I release the startup grid animation is executed.

from react-native-sortable-grid.

eduardojunio avatar eduardojunio commented on June 28, 2024

@indivisable what component FavoritesGrid is this? A SortableGrid children?

from react-native-sortable-grid.

dmkerfont avatar dmkerfont commented on June 28, 2024

@DanielMartini Worked perfectly! Thanks!

from react-native-sortable-grid.

midimurphdesigns avatar midimurphdesigns commented on June 28, 2024

The mentioned solutions work great except for one aspect I am struggling to find a solution for. If the user holds to drag the tile and doesn't move it before releasing, onDragRelease never fires and the page is stuck with scrolling disabled. Does anyone have a solution for this edge case?

from react-native-sortable-grid.

midimurphdesigns avatar midimurphdesigns commented on June 28, 2024

I found an ok solution by wrapping each child element in your grid with a touchableWithoutFeedback, and use the onPressIn and onPressOut handlers to toggle scrollingEnabled in the scrollview via setState.

from react-native-sortable-grid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.