-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cleanup: Cleanup: pass plugin component to renderMarkdown Cleanup: clear tab header aria label when dragging Cleanup: only show dragged elements if dragType matches Cleanup: dragTracker needs to track the dragType Cleanup: fix function ordering Cleanup: only act on matching drag moves Cleanup: pass dragType with dragData from typescript Cleanup: construct beaconType from a dragType Cleanup: move board reordering logic to the board page Cleanup: not using DragData.beaconType so remove it Cleanup: tidy Session function ordering and labelling Cleanup: fix typo: Session.timeWIthZoneIs -> timeWithZoneIs Cleanup: Beacon.identifier -> uniqueId Cleanup: move DragTracker into own module Cleanup: move BeaconPosition decoding into BeaconPosition module Cleanup: simplify dragged item placement offset calculations
- Loading branch information
Showing
15 changed files
with
620 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
module DragAndDrop.DragTracker exposing | ||
( ClientData | ||
, DragTracker(..) | ||
, dragType | ||
, init | ||
, isDragging | ||
, moveDragable | ||
, stopTracking | ||
, waitForDrag | ||
) | ||
|
||
import DragAndDrop.Coords as Coords exposing (Coords) | ||
import DragAndDrop.DragData exposing (DragData) | ||
import DragAndDrop.Rect as Rect exposing (Rect) | ||
|
||
|
||
|
||
-- TYPES | ||
|
||
|
||
type DragTracker | ||
= NotDragging | ||
| Waiting ClientData | ||
| Dragging ClientData DomData | ||
|
||
|
||
type alias ClientData = | ||
{ uniqueId : String | ||
, clientPos : Coords | ||
, offsetPos : Coords | ||
} | ||
|
||
|
||
type alias DomData = | ||
{ dragType : String | ||
, offset : Coords | ||
, draggedNodeStartRect : Rect | ||
} | ||
|
||
|
||
init : DragTracker | ||
init = | ||
NotDragging | ||
|
||
|
||
|
||
-- INFO | ||
|
||
|
||
dragType : DragTracker -> Maybe String | ||
dragType dragTracker = | ||
case dragTracker of | ||
NotDragging -> | ||
Nothing | ||
|
||
Waiting _ -> | ||
Nothing | ||
|
||
Dragging _ domData -> | ||
Just domData.dragType | ||
|
||
|
||
isDragging : DragTracker -> Bool | ||
isDragging dragTracker = | ||
case dragTracker of | ||
NotDragging -> | ||
False | ||
|
||
Waiting _ -> | ||
False | ||
|
||
Dragging _ _ -> | ||
True | ||
|
||
|
||
|
||
-- STATE TRANSFORMS | ||
|
||
|
||
moveDragable : DragData -> DragTracker -> DragTracker | ||
moveDragable dragData dragTracker = | ||
case dragTracker of | ||
NotDragging -> | ||
dragTracker | ||
|
||
Waiting clientData -> | ||
Dragging | ||
{ clientData | clientPos = dragData.cursor } | ||
{ offset = dragData.offset | ||
, draggedNodeStartRect = dragData.draggedNodeRect | ||
, dragType = dragData.dragType | ||
} | ||
|
||
Dragging clientData domData -> | ||
Dragging | ||
{ clientData | clientPos = dragData.cursor } | ||
{ domData | ||
| offset = dragData.offset | ||
, dragType = dragData.dragType | ||
} | ||
|
||
|
||
stopTracking : DragTracker | ||
stopTracking = | ||
NotDragging | ||
|
||
|
||
waitForDrag : ClientData -> DragTracker | ||
waitForDrag clientData = | ||
Waiting clientData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.