Skip to content

Commit

Permalink
consider initial wait time when adding a new queue of events. Also, u…
Browse files Browse the repository at this point in the history
…se the ending time of the last event instead of the starting time as the start for the new queued timeline.
  • Loading branch information
mdgriffith committed May 23, 2020
1 parent 7d550c2 commit 2489029
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions src/Internal/Timeline.elm
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ addEventsToLine now (Schedule delay scheduledStartingEvent reverseQueued) (Line
[] ->
let
startNewEventsAt =
Time.latest (startTime startingEvent) start
Time.latest (Time.advanceBy delay (endTime startingEvent)) start

startingEventWithDwell =
case startingEvent of
Expand All @@ -932,38 +932,29 @@ addEventsToLine now (Schedule delay scheduledStartingEvent reverseQueued) (Line
|> List.reverse
|> Line startLineAt startingEventWithDwell

(Occurring lastEvent lastEventTime _) :: eventTail ->
(Occurring lastEvent lastEventTime lastEventFinish) :: eventTail ->
let
startNewEventsAt =
Time.latest lastEventTime start
Time.latest (Time.advanceBy delay lastEventFinish) start

newEvents =
List.foldl toOccurring ( startNewEventsAt, [] ) queued
|> Tuple.second
|> List.reverse
in
if Time.thisAfterOrEqualThat start lastEventTime then
-- if the start of the scheduled events is after the last event time,
-- then we need to increase the dwell time of the last event to match the start time.
let
newLastEvent =
Occurring lastEvent
lastEventTime
(if Time.thisAfterThat start lastEventTime then
start

else
lastEventTime
)
in
Line startLineAt
startingEvent
(List.reverse (newLastEvent :: eventTail)
++ newEvents
)

else
Line startLineAt startingEvent (events ++ newEvents)
-- we need to increase the dwell time of the last event
-- to match the start time of the new queued events.
let
newLastEvent =
Occurring lastEvent
lastEventTime
startNewEventsAt
in
Line startLineAt
startingEvent
(List.reverse (newLastEvent :: eventTail)
++ newEvents
)


toOccurring : Event event -> ( Time.Absolute, List (Occurring event) ) -> ( Time.Absolute, List (Occurring event) )
Expand Down

0 comments on commit 2489029

Please sign in to comment.