react-rnd icon indicating copy to clipboard operation
react-rnd copied to clipboard

Feature Request: Component follow scroll

Open wootencl opened this issue 6 years ago • 4 comments

First of all, want to say thanks for the excellent module and all the hard work you've put into it :)

Onto my feature request/enhancement: Would be great if the draggable component would follow along as the page is scrolled. Would be useful in the scenario where you have a parent container that has a height greater than the viewport and you wish to drag the component to an area outside of the current viewport (but still within the bounds of the parent).

Currently the mouse will continue to scroll down (desired effect), but the draggable component will halt at where the viewport border is/was.

Reproduced project

https://codesandbox.io/s/l2knp9y8oq

Quick gif of the current functionality:

(apologies for the poor quality 😞) Alt Text

wootencl avatar Jul 05 '18 20:07 wootencl

This would be a great enhancement. Has anyone figured out a work around in the mean time?

rjtwoh01 avatar Mar 25 '19 14:03 rjtwoh01

Apoiado

JosemarVarela avatar May 01 '21 23:05 JosemarVarela

add the style position: absolute; to the container div.

aruggles avatar Sep 16 '21 20:09 aruggles

You can achieve this by applying the following style to the outer container <Rnd> is in:

{
  position: "fixed",
  top: 0,
  right: 0,
  bottom: 0,
  left: 0,
  pointerEvents: "none"
}

The outer container is now above all other content (maybe set zIndex as well). If we don't set pointerEvents: "none", the content behind the outer container wouldn't be clickable. Not sure if this method is wise in terms of accessibility, though.

At last, pointerEvents needs to be reset on the <Rnd>-element (pointerEvents: "auto"), to make content inside the <Rnd>-element clickable again (if needed).

I modified your codesandbox to give an example: https://codesandbox.io/s/exciting-solomon-nqb32

gambolputty avatar Feb 14 '22 18:02 gambolputty