fixed bug when scrolling terminal when is closed

pull/5370/head
Josel95 3 years ago
parent b53591f99d
commit cc5a763083
  1. 10
      libs/remix-ui/terminal/src/lib/custom-hooks/useDragTerminal.tsx

@ -4,6 +4,8 @@ export const useDragTerminal = (offsetHeight: number) => {
const [isOpen, setIsOpen] = useState(true) const [isOpen, setIsOpen] = useState(true)
const [lastYPosition, setLastYPosition] = useState(0) const [lastYPosition, setLastYPosition] = useState(0)
const [terminalPosition, setTerminalPosition] = useState(offsetHeight) const [terminalPosition, setTerminalPosition] = useState(offsetHeight)
// Used to save position of the terminal when it is closed
const [lastTerminalPosition, setLastTerminalPosition] = useState(offsetHeight)
const [isDragging, setIsDragging] = useState(false) const [isDragging, setIsDragging] = useState(false)
const handleDraggingStart = (event: React.MouseEvent) => { const handleDraggingStart = (event: React.MouseEvent) => {
@ -36,6 +38,14 @@ export const useDragTerminal = (offsetHeight: number) => {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
if(isOpen) {
setLastTerminalPosition(terminalPosition)
setLastYPosition(0)
setTerminalPosition(offsetHeight)
} else {
setTerminalPosition(lastTerminalPosition)
}
setIsOpen(!isOpen) setIsOpen(!isOpen)
} }

Loading…
Cancel
Save