We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This was my solution:
constructor(props) { super(props); this.carouselSettings = {..., touchThreshold: 5, ...}; // explicitly set touchThreshold since we reference it later this.preventTouch = this.preventTouch.bind(this); this.touchStart = this.touchStart.bind(this); } componentDidMount() { // Disable touchmove to prevent scrolling entire page const carousel = document.getElementById('someid'); // Your site element containing react-slick's carousel-container carousel.addEventListener('touchstart', this.touchStart); carousel.addEventListener('touchmove', this.preventTouch, { passive: false }); } touchStart(e) { // capture user's starting finger position, for later comparison this.firstClientX = e.touches[0].clientX; } preventTouch(e) { // only prevent touch on horizontal scroll (for horizontal carousel) // this allows the users to scroll vertically past the carousel when touching the carousel // this also stabilizes the horizontal scroll somewhat, decreasing vertical scroll while horizontal scrolling const clientX = e.touches[0].clientX - this.firstClientX; const horizontalScroll = Math.abs(clientX) > this.carouselSettings.touchThreshold; if (horizontalScroll) { e.preventDefault(); } }
Thanks to @yunyong for his helpful comment.
Originally posted by @randallreedjr in #1281 (comment)
The text was updated successfully, but these errors were encountered:
This solution worked but now my vertical scroll is not working
Sorry, something went wrong.
No branches or pull requests
This was my solution:
Thanks to @yunyong for his helpful comment.
Originally posted by @randallreedjr in #1281 (comment)
The text was updated successfully, but these errors were encountered: