Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
122
Issues
122
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
1d668acf
Commit
1d668acf
authored
Jun 24, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
intermediate commit of RangeSlider
parent
577ad6a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
RangeSlider.purs
src/Gargantext/Components/RangeSlider.purs
+12
-8
No files found.
src/Gargantext/Components/RangeSlider.purs
View file @
1d668acf
...
...
@@ -14,6 +14,7 @@ import DOM.Simple.Document (document)
import DOM.Simple.EventListener as EL
import DOM.Simple.Types (DOMRect, Element)
import DOM.Simple.Event as Event
import DOM.Simple.Console (log, log2)
import Data.Tuple.Nested ((/\))
import Effect.Uncurried (EffectFn1, mkEffectFn1)
import Gargantext.Utils.Math (roundToMultiple)
...
...
@@ -50,6 +51,7 @@ rangeSliderCpt :: R.Component Props
rangeSliderCpt = R.hooksComponent "RangeSlider" cpt
where
cpt props _ = do
R.useEffect' $ \_ -> log2 "Props: " props
-- scale bar
scaleElem <- R.useRef null -- dom ref
scalePos <- R2.usePositionRef scaleElem
...
...
@@ -70,8 +72,9 @@ rangeSliderCpt = R.hooksComponent "RangeSlider" cpt
-- the handler functions for trapping mouse events, so they can be removed
mouseMoveHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
mouseUpHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
let destroy =
do destroyEventHandler "mousemove" mouseMoveHandler
let destroy = \_ ->
do log "RangeSlider: Destroying event handlers"
destroyEventHandler "mousemove" mouseMoveHandler
destroyEventHandler "mouseup" mouseUpHandler
R2.useLayoutEffect1' dragKnob $ \_ -> do
case dragKnob of
...
...
@@ -81,11 +84,12 @@ rangeSliderCpt = R.hooksComponent "RangeSlider" cpt
let onMouseMove = EL.callback $ \(event :: Event.MouseEvent) ->
case reproject drag scalePos value (R2.domMousePosition event) of
Just val -> setKnob knob setValue value val
Nothing -> destroy
let onMouseUp = EL.callback $ \(_event :: Event.MouseEvent) -> destroy
Nothing -> destroy unit
let onMouseUp = EL.callback $ \(_event :: Event.MouseEvent) -> destroy unit
log "RangeSlider: Creating event handlers"
EL.addEventListener document "mousemove" onMouseMove
EL.addEventListener document "mouseup" onMouseUp
Nothing -> destroy
Nothing -> destroy
unit
pure $ H.div { className, aria }
[ renderScale scaleElem props value'
, renderKnob lowElem value'.min ("Minimum value:" <> show value'.min) MinKnob setDragKnob
...
...
@@ -129,9 +133,9 @@ renderScale ref {width,height} {min, max} =
aria = { label: "Scale running from " <> show min <> " to " <> show max }
renderKnob ref val label knob set =
H.div { ref, tab
i
ndex, className, aria, onMouseDown } [ H.text (show val) ]
H.div { ref, tab
I
ndex, className, aria, onMouseDown } [ H.text (show val) ]
where
tab
i
ndex = 0
tab
I
ndex = 0
className = "knob"
aria = { label }
onMouseDown = mkEffectFn1 $ \_ -> set (Just knob)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment