Skip to content

Commit

Permalink
improve auto-scroll for doc panel
Browse files Browse the repository at this point in the history
  • Loading branch information
shmish111 committed Jul 9, 2020
1 parent d3db814 commit 0461760
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions marlowe-playground-client/src/Simulation.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Data.BigInteger (BigInteger, fromString, fromInt)
import Data.Either (Either(..), note)
import Data.Enum (toEnum, upFromIncluding)
import Data.HeytingAlgebra (not, (&&))
import Data.Int (toNumber)
import Data.Lens (_Just, assign, modifying, over, preview, to, use, view, (^.))
import Data.Lens.Index (ix)
import Data.Lens.NonEmptyList (_Head)
Expand Down Expand Up @@ -65,7 +66,7 @@ import Monaco (IMarker, isError, isWarning)
import Monaco (getModel, getMonaco, setTheme, setValue) as Monaco
import Network.RemoteData (RemoteData(..), _Success)
import Network.RemoteData as RemoteData
import Prelude (class Show, Unit, add, bind, bottom, const, discard, eq, flip, identity, mempty, one, pure, show, unit, zero, ($), (/=), (<$>), (<<<), (<>), (=<<), (==), (>))
import Prelude (class Show, Unit, add, bind, bottom, const, discard, eq, flip, identity, mempty, one, pure, show, unit, zero, ($), (/=), (<$>), (<<<), (<>), (=<<), (==), (>), (-), (<))
import Servant.PureScript.Ajax (AjaxError, errorToString)
import Servant.PureScript.Settings (SPSettings_)
import Simulation.BottomPanel (bottomPanel)
Expand All @@ -82,6 +83,7 @@ import Web.DOM.HTMLCollection as WC
import Web.HTML as Web
import Web.HTML.HTMLDocument (toDocument)
import Web.HTML.Window as W
import Web.HTML.Window as Window
import WebSocket (WebSocketRequestMessage(..))

mkComponent :: forall m. MonadEffect m => MonadAff m => SPSettings_ SPParams_ -> H.Component HTML Query Unit Message m
Expand Down Expand Up @@ -371,11 +373,15 @@ scrollHelpPanel =
window <- Web.window
document <- toDocument <$> W.document window
mSidePanel <- WC.item 0 =<< D.getElementsByClassName "sidebar-composer" document
case mSidePanel of
Nothing -> pure unit
Just sidePanel -> do
scrollHeight <- E.scrollHeight sidePanel
setScrollTop scrollHeight sidePanel
mDocPanel <- WC.item 0 =<< D.getElementsByClassName "documentation-panel" document
case mSidePanel, mDocPanel of
Just sidePanel, Just docPanel -> do
sidePanelHeight <- E.scrollHeight sidePanel
docPanelHeight <- E.scrollHeight docPanel
let
availableHeight = sidePanelHeight - docPanelHeight - 100.0
setScrollTop availableHeight sidePanel
_, _ -> pure unit

editorSetValue :: forall m. String -> HalogenM State Action ChildSlots Message m Unit
editorSetValue contents = void $ query _editorSlot unit (Monaco.SetText contents unit)
Expand Down

0 comments on commit 0461760

Please sign in to comment.