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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
5713d19c
Commit
5713d19c
authored
Aug 19, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] RangeSlider logs, knob position adjusting still doesn't work
parent
b9137508
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
+30
-23
RangeSlider.purs
src/Gargantext/Components/RangeSlider.purs
+30
-23
No files found.
src/Gargantext/Components/RangeSlider.purs
View file @
5713d19c
...
@@ -8,12 +8,14 @@ module Gargantext.Components.RangeSlider where
...
@@ -8,12 +8,14 @@ module Gargantext.Components.RangeSlider where
import Prelude
import Prelude
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (
null
)
import Data.Nullable (
Nullable, null, toMaybe
)
import Data.Traversable (traverse_)
import Data.Traversable (traverse_)
import Effect (Effect)
import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Uncurried (EffectFn1, mkEffectFn1)
import Effect.Uncurried (EffectFn1, mkEffectFn1)
import DOM.Simple as DOM
import DOM.Simple.Document (document)
import DOM.Simple.Document (document)
import DOM.Simple.Element as Element
import DOM.Simple.EventListener as EL
import DOM.Simple.EventListener as EL
import DOM.Simple.Types (DOMRect, Element)
import DOM.Simple.Types (DOMRect, Element)
import DOM.Simple.Event as Event
import DOM.Simple.Event as Event
...
@@ -71,37 +73,42 @@ rangeSliderCpt = R.hooksComponent "RangeSlider" cpt
...
@@ -71,37 +73,42 @@ rangeSliderCpt = R.hooksComponent "RangeSlider" cpt
-- the knob we are currently in a drag for. set by mousedown on a knob
-- the knob we are currently in a drag for. set by mousedown on a knob
dragKnob /\ setDragKnob <- R.useState' $ (Nothing :: Maybe Knob)
dragKnob /\ setDragKnob <- R.useState' $ (Nothing :: Maybe Knob)
-- the bounding box within which the mouse can drag
-- the bounding box within which the mouse can drag
dragScale <- R.useRef $ Nothing
--
dragScale <- R.useRef $ Nothing
-- the handler functions for trapping mouse events, so they can be removed
-- 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)))
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)))
mouseUpHandler <- (R.useRef $ Nothing) :: R.Hooks (R.Ref (Maybe (EL.Callback Event.MouseEvent)))
let destroy = \_ ->
let destroy = \_ ->
do
do
log "RangeSlider: Destroying event handlers"
log "RangeSlider: Destroying event handlers"
destroyEventHandler "mousemove" mouseMoveHandler
destroyEventHandler "mousemove" mouseMoveHandler
destroyEventHandler "mouseup" mouseUpHandler
destroyEventHandler "mouseup" mouseUpHandler
R.setRef mouseMoveHandler $ Nothing
R.setRef mouseUpHandler $ Nothing
R2.useLayoutEffect1' dragKnob $ \_ -> do
R2.useLayoutEffect1' dragKnob $ \_ -> do
case dragKnob of
case dragKnob of
Just knob -> do
Just knob -> do
let drag = (getDragScale knob scalePos lowPos highPos) :: Maybe Range.NumberRange
let drag = (getDragScale knob scalePos lowPos highPos) :: Maybe Range.NumberRange
R.setRef dragScale drag
--
R.setRef dragScale drag
let onMouseMove = EL.callback $ \(event :: Event.MouseEvent) -> do
let onMouseMove = EL.callback $ \(event :: Event.MouseEvent) -> do
-- log2 "drag" drag
log2 "dragKnob" dragKnob
-- log2 "scale" scalePos
log2 "lowPos" lowPos
-- -- log2 "value" value
log2 "highPos" highPos
-- let (R2.Point mousePos) = R2.domMousePosition event
log2 "drag" drag
-- log2 "mouse position" mousePos
log2 "scale" scalePos
-- let scale = rectRange <$> R.readRef scalePos
-- log2 "value" value
-- case scale of
let (R2.Point mousePos) = R2.domMousePosition event
-- Just scale_ ->
log2 "mouse position" mousePos
-- case drag of
let scale = rectRange <$> R.readRef scalePos
-- Just drag_ -> do
case scale of
-- let normal = Range.normalise scale_ (Range.clamp drag_ mousePos.x)
Just scale_ ->
-- log2 "normal" normal
case drag of
-- log2 "project normal" $ Range.projectNormal props.bounds normal
Just drag_ -> do
-- _ -> log "drag is Nothing"
let normal = Range.normalise scale_ (Range.clamp drag_ mousePos.x)
-- _ -> log "scale is Nothing"
log2 "normal" normal
log2 "project normal" $ Range.projectNormal props.bounds normal
_ -> log "drag is Nothing"
_ -> log "scale is Nothing"
case reproject drag scalePos props.bounds (R2.domMousePosition event) of
case reproject drag scalePos props.bounds (R2.domMousePosition event) of
Just val -> do
Just val -> do
...
...
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