@@ -396,7 +396,7 @@ const LPTimeTableImpl = <G extends TimeTableGroup, I extends TimeSlotBooking>({
396396 const nowbarScrollHandling = useCallback ( ( ) => {
397397 if ( nowTimeSlotRef ?. current ) {
398398 rateLimiter ( ( ) =>
399- nowbarRemoveCoveredCheck (
399+ nowbarCoveredCheck (
400400 nowBarRef ,
401401 tableHeaderRef ,
402402 nowTimeSlotRef ,
@@ -449,6 +449,7 @@ const LPTimeTableImpl = <G extends TimeTableGroup, I extends TimeSlotBooking>({
449449 timeFrameDay ,
450450 currViewType ,
451451 groupHeaderColumnWidth ,
452+ timeStepsMinutes ,
452453 setMessage ,
453454 )
454455 } , [
@@ -458,6 +459,7 @@ const LPTimeTableImpl = <G extends TimeTableGroup, I extends TimeSlotBooking>({
458459 currViewType ,
459460 setMessage ,
460461 groupHeaderColumnWidth ,
462+ timeStepsMinutes ,
461463 ] )
462464
463465 // initial run, and start interval to move the now bar
@@ -553,6 +555,7 @@ const LPTimeTableImpl = <G extends TimeTableGroup, I extends TimeSlotBooking>({
553555 customHeaderRow = { customHeaderRow }
554556 entries = { entries }
555557 tableHeaderRef = { tableHeaderRef }
558+ timeStepMinutesHoursView = { timeStepsMinutes }
556559 />
557560 < tbody ref = { tableBodyRef } className = "table-fixed" >
558561 < TimeTableRows < G , I >
@@ -567,6 +570,7 @@ const LPTimeTableImpl = <G extends TimeTableGroup, I extends TimeSlotBooking>({
567570 slotsArray = { slotsArray }
568571 timeFrameDay = { timeFrameDay }
569572 viewType = { currViewType }
573+ timeStepMinutesHoursView = { timeStepsMinutes }
570574 />
571575 </ tbody >
572576 </ table >
@@ -596,6 +600,7 @@ function moveNowBar(
596600 timeFrameDay : TimeFrameDay ,
597601 viewType : TimeTableViewType ,
598602 groupHeaderColumnWidth : number ,
603+ timeStepMinutes : number ,
599604 setMessage ?: ( message : TimeTableMessage ) => void ,
600605) {
601606 if ( ! tableHeaderRef . current || ! tableBodyRef . current ) {
@@ -660,6 +665,15 @@ function moveNowBar(
660665 timeFrameDay ,
661666 viewType ,
662667 )
668+
669+ /*const insideOfTimeFrameOfDay =
670+ now.hour() > timeFrameDay.startHour ||
671+ (now.hour() === timeFrameDay.startHour &&
672+ now.minute() > timeFrameDay.startMinute &&
673+ now.hour() < timeFrameDay.endHour) ||
674+ (now.hour() === timeFrameDay.endHour &&
675+ now.minute() < timeFrameDay.endMinute)*/
676+
663677 if ( startAndEndSlot . status !== "in" ) {
664678 // we need to remove the now bar, if it is there
665679 if ( nowBar ) {
@@ -686,32 +700,46 @@ function moveNowBar(
686700
687701 if ( ! nowBar ) {
688702 nowBar = document . createElement ( "div" )
689- //nowBar.className = styles.nowBar
690703 nowBar . className =
691704 "absolute opacity-60 bg-orange-bold top-0 bottom-0 z-[2] w-[2px]"
692- //slotBar.appendChild( nowBar)
705+ nowBar . id = " nowBar"
693706 nowBarRef . current = nowBar
694- nowbarRemoveCoveredCheck (
695- nowBarRef ,
696- tableHeaderRef ,
697- nowTimeSlotRef ,
698- groupHeaderColumnWidth ,
699- )
700707 }
701708
702- const currentTimeSlot = slotsArray [ startSlot ]
709+ let currentTimeSlot = slotsArray [ startSlot ]
703710 const timeSlotMinutes = getTimeSlotMinutes (
704711 currentTimeSlot ,
705712 timeFrameDay ,
706713 viewType ,
714+ timeStepMinutes ,
707715 )
716+
717+ if ( viewType !== "hours" ) {
718+ // see getTimeSlotMinutes in timeTableUtils
719+ currentTimeSlot = currentTimeSlot
720+ . add ( timeFrameDay . startHour , "hours" )
721+ . add ( timeFrameDay . startMinute , "minutes" )
722+ }
723+
708724 const diffNow = now . diff ( currentTimeSlot , "minutes" )
709725
710726 const diffPerc = diffNow / timeSlotMinutes
727+
711728 nowBar . style . left = `${ diffPerc * 100 } %`
712729 nowBar . style . top = "100%"
713730 nowBar . style . height = `${ tableBody . getBoundingClientRect ( ) . bottom - nowTimeSlotCell . getBoundingClientRect ( ) . top - nowTimeSlotCell . clientHeight } px`
714731
732+ if ( nowBarRef . current && nowTimeSlotRef . current ) {
733+ nowTimeSlotRef . current . appendChild ( nowBarRef . current )
734+ nowbarCoveredCheck (
735+ nowBarRef ,
736+ tableHeaderRef ,
737+ nowTimeSlotRef ,
738+ groupHeaderColumnWidth ,
739+ )
740+ }
741+
742+ // orange bottom border of the now time slot cell
715743 nowTimeSlotCell . classList . remove (
716744 "border-b-border-bold" ,
717745 "font-normal" ,
@@ -752,7 +780,7 @@ function moveNowBar(
752780 * @param nowBarRef
753781 * @param tableHeaderRef
754782 */
755- function nowbarRemoveCoveredCheck (
783+ function nowbarCoveredCheck (
756784 nowBarRef : MutableRefObject < HTMLDivElement | undefined > ,
757785 tableHeaderRef : MutableRefObject < HTMLTableSectionElement | null > ,
758786 nowTimeSlotRef : MutableRefObject < HTMLTableCellElement | undefined > ,
@@ -761,23 +789,23 @@ function nowbarRemoveCoveredCheck(
761789 if ( ! nowTimeSlotRef . current ) {
762790 return
763791 }
792+
764793 const tableHeader = tableHeaderRef . current
765794 // the first TH is the sticky group header column
766795 const tableHeaderFirstTH = tableHeader ?. children [ 0 ] ?. children [ 0 ]
767796 const rightNowbarBorder =
768797 tableHeaderFirstTH ?. getBoundingClientRect ( ) . right ||
769798 groupHeaderColumnWidth
770799 const nowTimeSlotLeft = nowTimeSlotRef . current . getBoundingClientRect ( ) . left
800+
771801 if ( nowTimeSlotLeft <= rightNowbarBorder ) {
772802 if ( nowBarRef . current ?. parentElement ) {
773803 const nowBarRect = nowBarRef . current . getBoundingClientRect ( )
774804 if ( nowBarRect . left <= rightNowbarBorder ) {
775- nowBarRef . current . remove ( )
805+ nowBarRef . current . classList . add ( "hidden" )
776806 }
777807 }
778808 } else {
779- if ( nowBarRef . current && ! nowBarRef . current . parentElement ) {
780- nowTimeSlotRef . current . appendChild ( nowBarRef . current )
781- }
809+ nowBarRef . current ?. classList . remove ( "hidden" )
782810 }
783811}
0 commit comments