@@ -82,9 +82,6 @@ export default class TimeGrid extends Component {
8282
8383 this . applyScroll ( )
8484
85- this . positionTimeIndicator ( )
86- this . triggerTimeIndicatorUpdate ( )
87-
8885 window . addEventListener ( 'resize' , this . handleResize )
8986 }
9087
@@ -99,7 +96,6 @@ export default class TimeGrid extends Component {
9996 this . rafHandle = raf ( this . checkOverflow )
10097 }
10198 componentWillUnmount ( ) {
102- window . clearTimeout ( this . _timeIndicatorTimeout )
10399 window . removeEventListener ( 'resize' , this . handleResize )
104100
105101 raf . cancel ( this . rafHandle )
@@ -111,7 +107,6 @@ export default class TimeGrid extends Component {
111107 }
112108
113109 this . applyScroll ( )
114- this . positionTimeIndicator ( )
115110 //this.checkOverflow()
116111 }
117112
@@ -146,7 +141,7 @@ export default class TimeGrid extends Component {
146141 } )
147142 }
148143
149- renderEvents ( range , events , today ) {
144+ renderEvents ( range , events , now ) {
150145 let { min, max, components, accessors, localizer } = this . props
151146
152147 const groupedEvents = this . resources . groupEvents ( events )
@@ -170,7 +165,7 @@ export default class TimeGrid extends Component {
170165 max = { dates . merge ( date , max ) }
171166 resource = { resource && id }
172167 components = { components }
173- className = { cn ( { 'rbc-now' : dates . eq ( date , today , 'day' ) } ) }
168+ isNow = { dates . eq ( date , now , 'day' ) }
174169 key = { i + '-' + jj }
175170 date = { date }
176171 events = { daysEvents }
@@ -270,8 +265,6 @@ export default class TimeGrid extends Component {
270265 className = "rbc-time-gutter"
271266 />
272267 { this . renderEvents ( range , rangeEvents , getNow ( ) ) }
273-
274- < div ref = "timeIndicator" className = "rbc-current-time-indicator" />
275268 </ div >
276269 </ div >
277270 )
@@ -321,45 +314,4 @@ export default class TimeGrid extends Component {
321314 } )
322315 }
323316 }
324-
325- positionTimeIndicator ( ) {
326- const { rtl, min, max, getNow, range } = this . props
327- const current = getNow ( )
328-
329- const secondsGrid = dates . diff ( max , min , 'seconds' )
330- const secondsPassed = dates . diff ( current , min , 'seconds' )
331-
332- const timeIndicator = this . refs . timeIndicator
333- const factor = secondsPassed / secondsGrid
334- const timeGutter = this . gutter
335-
336- const content = this . refs . content
337-
338- if ( timeGutter && current >= min && current <= max ) {
339- const pixelHeight = timeGutter . offsetHeight
340- const dayPixelWidth =
341- ( content . offsetWidth - timeGutter . offsetWidth ) / this . slots
342- const dayOffset =
343- range . findIndex ( d => dates . eq ( d , dates . today ( ) , 'day' ) ) * dayPixelWidth
344- const offset = Math . floor ( factor * pixelHeight )
345-
346- timeIndicator . style . display = dayOffset >= 0 ? 'block' : 'none'
347- timeIndicator . style [ rtl ? 'left' : 'right' ] = 0
348- timeIndicator . style [ rtl ? 'right' : 'left' ] =
349- timeGutter . offsetWidth + dayOffset + 'px'
350- timeIndicator . style . top = offset + 'px'
351- timeIndicator . style . width = dayPixelWidth + 'px'
352- } else {
353- timeIndicator . style . display = 'none'
354- }
355- }
356-
357- triggerTimeIndicatorUpdate ( ) {
358- // Update the position of the time indicator every minute
359- this . _timeIndicatorTimeout = window . setTimeout ( ( ) => {
360- this . positionTimeIndicator ( )
361-
362- this . triggerTimeIndicatorUpdate ( )
363- } , 60000 )
364- }
365317}
0 commit comments