roerohan / react-vnc

A React Component to connect to a websockified VNC client using noVNC.
https://roerohan.github.io/react-vnc/
MIT License
88 stars 21 forks source link

can not change clipViewport and dragViewport state #17

Closed salar-amr closed 2 years ago

salar-amr commented 2 years ago

hello , I noticed a button in pure no-vnc sdk which could change the state of clipViewport and dragViewport (true <=> false)

I implemented same strategy to get the same result but changing the state of these props does not change the behavior of vnc screen, I faced this issue since the height of vnc screen is always more than the device and some time there is a need to drag the view to see the bottom of screen but when the clipViewport and dragViewport is true scrolling with touch events in mobile devices does not scroll the content of shared application

roerohan commented 2 years ago

@salar-amr https://github.com/roerohan/react-vnc/blob/01afe07b5801087fbf11fec366896c980986ac54/src/lib/VncScreen.tsx#L74-L75

I just take the props and pass them in the noVNC library. When you used noVNC directly, can you show me your implementation that made it work? Maybe that will give me some insight into why this is failing.

roerohan commented 2 years ago

In #26, I've exposed the rfb object. So, if you have a code snippet like:

function App() {
  const vncScreenRef = useRef<React.ElementRef<typeof VncScreen>>(null);

  return (
    <VncScreen
      url={vncUrl}
      scaleViewport
      debug
      ref={vncScreenRef}
    />
  )
}

You can access the rfb object using vncScreenRef.current?.rfb. If the rfb object isn't set, it's value is null.