davidpomerenke commited on
Commit
df896ad
·
verified ·
1 Parent(s): 2250385

Upload from GitHub Actions: trying to fix figure pointing

Browse files
Files changed (1) hide show
  1. frontend/src/App.js +22 -2
frontend/src/App.js CHANGED
@@ -23,6 +23,8 @@ function App () {
23
  const [dialogVisible, setDialogVisible] = useState(false)
24
  const [aboutVisible, setAboutVisible] = useState(false)
25
  const [contributeVisible, setContributeVisible] = useState(false)
 
 
26
 
27
  useEffect(() => {
28
  fetch('/api/data', {
@@ -57,6 +59,20 @@ function App () {
57
  return () => window.removeEventListener('resize', handleResize)
58
  }, [])
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  return (
61
  <PrimeReactProvider>
62
  <div
@@ -267,6 +283,7 @@ function App () {
267
  }}
268
  />
269
  <Carousel
 
270
  value={[
271
  <WorldMap data={data.countries} allLanguages={data.language_table} />,
272
  <LanguagePlot data={data} />,
@@ -278,7 +295,8 @@ function App () {
278
  numVisible={1}
279
  itemTemplate={item => item}
280
  circular
281
- activeIndex={0}
 
282
  style={{ width: '100%', minHeight: '650px' }}
283
  />
284
  </div>
@@ -431,6 +449,7 @@ function App () {
431
  {data && (
432
  <div style={{ width: '100%', height: '100%' }}>
433
  <Carousel
 
434
  value={[
435
  <WorldMap
436
  data={data.countries}
@@ -459,7 +478,8 @@ function App () {
459
  numVisible={1}
460
  itemTemplate={item => item}
461
  circular
462
- activeIndex={0}
 
463
  style={{ width: '100%', height: 'calc(90vh - 120px)' }}
464
  />
465
  </div>
 
23
  const [dialogVisible, setDialogVisible] = useState(false)
24
  const [aboutVisible, setAboutVisible] = useState(false)
25
  const [contributeVisible, setContributeVisible] = useState(false)
26
+ const [carouselActiveIndex, setCarouselActiveIndex] = useState(0)
27
+ const [dialogCarouselActiveIndex, setDialogCarouselActiveIndex] = useState(0)
28
 
29
  useEffect(() => {
30
  fetch('/api/data', {
 
59
  return () => window.removeEventListener('resize', handleResize)
60
  }, [])
61
 
62
+ // Reset carousel indices when dialog opens/closes
63
+ useEffect(() => {
64
+ if (!dialogVisible) {
65
+ setDialogCarouselActiveIndex(0)
66
+ }
67
+ }, [dialogVisible])
68
+
69
+ // Reset main carousel index when data changes
70
+ useEffect(() => {
71
+ if (data) {
72
+ setCarouselActiveIndex(0)
73
+ }
74
+ }, [data])
75
+
76
  return (
77
  <PrimeReactProvider>
78
  <div
 
283
  }}
284
  />
285
  <Carousel
286
+ key={`main-carousel-${carouselActiveIndex}`}
287
  value={[
288
  <WorldMap data={data.countries} allLanguages={data.language_table} />,
289
  <LanguagePlot data={data} />,
 
295
  numVisible={1}
296
  itemTemplate={item => item}
297
  circular
298
+ activeIndex={carouselActiveIndex}
299
+ onPageChange={(e) => setCarouselActiveIndex(e.page)}
300
  style={{ width: '100%', minHeight: '650px' }}
301
  />
302
  </div>
 
449
  {data && (
450
  <div style={{ width: '100%', height: '100%' }}>
451
  <Carousel
452
+ key={`dialog-carousel-${dialogCarouselActiveIndex}`}
453
  value={[
454
  <WorldMap
455
  data={data.countries}
 
478
  numVisible={1}
479
  itemTemplate={item => item}
480
  circular
481
+ activeIndex={dialogCarouselActiveIndex}
482
+ onPageChange={(e) => setDialogCarouselActiveIndex(e.page)}
483
  style={{ width: '100%', height: 'calc(90vh - 120px)' }}
484
  />
485
  </div>