Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Drag and Drop with resizing browser window (react-use-gesture)

I used hook useDrag from 'react-use-gesture'.

 const drag = useDrag((params) => {},
        {
            bounds: {...bounds}
        }
    )

I use bounds in full clientWidth.

It works fine with constant bounds. But after resizing browser window (open devtools panel in my case) hook use previous offset value(I need to drag all width of resizing clientWidth).

How can I use useDrag with document.body.clientWidth?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found solution. If we need dynamic bounds we can rewrite values in hook callback

 const bind = useGesture({
            onDrag: (params) => {
                      params._bounds[0] = [1, smth1];

                      if (params.offset[0] > smth2) {
                          params.lastOffset[0] = smth2
                          params.offset[0] = smth2
                      }
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!