1- import { faPlay } from '@fortawesome/free-solid-svg-icons' ;
1+ import { faPause , faPlay } from '@fortawesome/free-solid-svg-icons' ;
22import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
33import { Button , Slider } from '@jupyter/react-components' ;
44import { IJupyterGISModel } from '@jupytergis/schema' ;
@@ -141,6 +141,7 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
141141 const max = Math . max ( ...convertedValues ) ;
142142
143143 // Update the range and minMax state
144+ console . log ( 'check' ) ;
144145 setCurrentValue ( min ) ;
145146 setMinMax ( { min, max } ) ;
146147 setRange ( { start : min , end : min + step } ) ;
@@ -178,16 +179,18 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
178179 } ;
179180
180181 const handleChange = ( e : any ) => {
181- const currentValueString = millisecondsToDateString (
182- + e . target . value ,
183- inferredDateFormat
184- ) ;
185- console . log ( 'currentValueString' , currentValueString ) ;
182+ // const currentValueStringTarget = millisecondsToDateString(
183+ // +e.target.value,
184+ // inferredDateFormat
185+ // );
186186
187+ // console.log('currentValueString target', currentValueStringTarget);
188+
189+ console . log ( '+e.target.value' , + e . target . value ) ;
187190 setCurrentValue ( + e . target . value ) ;
188191 setRange ( { start : + e . target . value , end : + e . target . value + step } ) ;
189192
190- // applyFilter(+e.target.value);
193+ applyFilter ( + e . target . value ) ;
191194 } ;
192195
193196 const applyFilter = ( value : number ) => {
@@ -235,14 +238,20 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
235238 } ;
236239
237240 useEffect ( ( ) => {
238- console . log (
239- 'currentValue' ,
240- millisecondsToDateString ( currentValue , inferredDateFormat )
241+ // console.log(
242+ // 'currentValue',
243+ // millisecondsToDateString(currentValue, inferredDateFormat)
244+ // );
245+ // applyFilter(currentValue);
246+
247+ const currentValueStringCurrent = millisecondsToDateString (
248+ currentValue ,
249+ inferredDateFormat
241250 ) ;
242- applyFilter ( currentValue ) ;
251+ console . log ( 'currentValueString current' , currentValueStringCurrent ) ;
243252 } , [ currentValue ] ) ;
244253
245- const handleAnimation = ( ) => {
254+ const playAnimation = ( ) => {
246255 // Clear any existing interval first
247256 if ( intervalRef . current ) {
248257 clearInterval ( intervalRef . current ) ;
@@ -260,12 +269,12 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
260269 }
261270
262271 // Calculate next value with safety bounds
263- const nextValue = Math . min ( prev + step , minMax . max ) ;
272+ const nextValue = prev + step ;
264273
265274 // Clear interval if we've reached the max
266- if ( nextValue === minMax . max && intervalRef . current ) {
275+ if ( nextValue >= minMax . max - step && intervalRef . current ) {
267276 clearInterval ( intervalRef . current ) ;
268- return minMax . max - step ;
277+ return minMax . max - step ; // Ensure it reaches the exact max value
269278 }
270279
271280 return nextValue ;
@@ -278,6 +287,12 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
278287 // }
279288 } ;
280289
290+ const pauseAnimation = ( ) => {
291+ if ( intervalRef . current ) {
292+ clearInterval ( intervalRef . current ) ;
293+ }
294+ } ;
295+
281296 return (
282297 < div className = "jp-gis-temporal-slider-container" >
283298 { layerId ? (
@@ -302,18 +317,26 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
302317 </ div >
303318 { /* Current frame */ }
304319 < div >
305- Current Frame:{ ' ' }
306- { millisecondsToDateString ( range . start , inferredDateFormat ) } ≤ t ≤{ ' ' }
320+ < span > Current Frame:</ span > { ' ' }
321+ { millisecondsToDateString ( range . start , inferredDateFormat ) } ≤{ ' ' }
322+ < span > t</ span > ≤{ ' ' }
307323 { millisecondsToDateString ( range . end , inferredDateFormat ) }
308324 </ div >
309325 </ div >
310326 < div className = "jp-gis-temporal-slider-row" >
311327 { /* controls */ }
312- < div >
328+ < div style = { { margin : 'auto' } } >
329+ < Button
330+ appearance = "neutral"
331+ scale = "medium"
332+ onClick = { pauseAnimation }
333+ >
334+ < FontAwesomeIcon icon = { faPause } />
335+ </ Button >
313336 < Button
314337 appearance = "neutral"
315338 scale = "medium"
316- onClick = { handleAnimation }
339+ onClick = { playAnimation }
317340 >
318341 < FontAwesomeIcon icon = { faPlay } />
319342 </ Button >
@@ -333,8 +356,9 @@ const TemporalSlider = ({ model }: ITemporalSliderProps) => {
333356 < div className = "jp-gis-temporal-slider-row" >
334357 { /* range */ }
335358 < div >
336- Animation Range:{ ' ' }
337- { millisecondsToDateString ( minMax . min , inferredDateFormat ) } to{ ' ' }
359+ < span > Range: </ span >
360+ { millisecondsToDateString ( minMax . min , inferredDateFormat ) } { ' ' }
361+ < span > to </ span >
338362 { millisecondsToDateString ( minMax . max , inferredDateFormat ) }
339363 </ div >
340364 { /* step */ }
0 commit comments