@@ -115,8 +115,14 @@ const PrinciplesValuesShowcase = () => {
115115 const [ selectedValue , setSelectedValue ] = useState ( 0 ) ;
116116 const [ selectedPrinciple , setSelectedPrinciple ] = useState ( 0 ) ;
117117 const [ isHovered , setIsHovered ] = useState ( false ) ;
118+ const [ isValuesInView , setIsValuesInView ] = useState ( false ) ;
119+ const [ isPrinciplesInView , setIsPrinciplesInView ] = useState ( false ) ;
118120 const valuesIntervalRef = useRef < NodeJS . Timeout | null > ( null ) ;
119121 const principlesIntervalRef = useRef < NodeJS . Timeout | null > ( null ) ;
122+ const valuesSectionRef = useRef < HTMLDivElement > ( null ) ;
123+ const principlesSectionRef = useRef < HTMLDivElement > ( null ) ;
124+ const valuesNavRef = useRef < HTMLDivElement > ( null ) ;
125+ const principlesNavRef = useRef < HTMLDivElement > ( null ) ;
120126
121127 // Get translated data
122128 const getTranslatedValues = ( ) => [
@@ -206,26 +212,58 @@ const PrinciplesValuesShowcase = () => {
206212 const translatedValues = getTranslatedValues ( ) ;
207213 const translatedPrinciples = getTranslatedPrinciples ( ) ;
208214
209- // Auto-advance sliders every 5 seconds (pause on hover)
215+ // Intersection Observer for detecting when sections are in view
210216 useEffect ( ( ) => {
211- if ( ! isHovered ) {
217+ const observer = new IntersectionObserver (
218+ ( entries ) => {
219+ entries . forEach ( ( entry ) => {
220+ if ( entry . target === valuesSectionRef . current ) {
221+ setIsValuesInView ( entry . isIntersecting ) ;
222+ }
223+ if ( entry . target === principlesSectionRef . current ) {
224+ setIsPrinciplesInView ( entry . isIntersecting ) ;
225+ }
226+ } ) ;
227+ } ,
228+ { threshold : 0.3 }
229+ ) ;
230+
231+ if ( valuesSectionRef . current ) observer . observe ( valuesSectionRef . current ) ;
232+ if ( principlesSectionRef . current ) observer . observe ( principlesSectionRef . current ) ;
233+
234+ return ( ) => {
235+ if ( valuesSectionRef . current ) observer . unobserve ( valuesSectionRef . current ) ;
236+ if ( principlesSectionRef . current ) observer . unobserve ( principlesSectionRef . current ) ;
237+ } ;
238+ } , [ ] ) ;
239+
240+ // Auto-advance sliders every 5 seconds (pause on hover and only when in view)
241+ useEffect ( ( ) => {
242+ if ( ! isHovered && isValuesInView ) {
212243 valuesIntervalRef . current = setInterval ( ( ) => {
213244 setSelectedValue ( prev => ( prev + 1 ) % translatedValues . length ) ;
214245 } , 5000 ) ;
246+ }
215247
248+ return ( ) => {
249+ if ( valuesIntervalRef . current ) clearInterval ( valuesIntervalRef . current ) ;
250+ } ;
251+ } , [ isHovered , isValuesInView , translatedValues . length ] ) ;
252+
253+ useEffect ( ( ) => {
254+ if ( ! isHovered && isPrinciplesInView ) {
216255 principlesIntervalRef . current = setInterval ( ( ) => {
217256 setSelectedPrinciple ( prev => ( prev + 1 ) % translatedPrinciples . length ) ;
218257 } , 5000 ) ;
219258 }
220259
221260 return ( ) => {
222- if ( valuesIntervalRef . current ) clearInterval ( valuesIntervalRef . current ) ;
223261 if ( principlesIntervalRef . current ) clearInterval ( principlesIntervalRef . current ) ;
224262 } ;
225- } , [ isHovered , translatedValues . length , translatedPrinciples . length ] ) ;
263+ } , [ isHovered , isPrinciplesInView , translatedPrinciples . length ] ) ;
226264
227265 return (
228- < div className = "space-y-32 py-20" >
266+ < div id = "foundations" className = "space-y-32 py-20" >
229267 { /* Mission & Vision Section */ }
230268 < section className = "py-20" >
231269 < div className = "max-w-7xl mx-auto px-8" >
@@ -279,7 +317,7 @@ const PrinciplesValuesShowcase = () => {
279317 </ section >
280318
281319 { /* Principles Section with Manual Slider */ }
282- < section className = "py-20" >
320+ < section ref = { principlesSectionRef } className = "py-20" >
283321 < div className = "max-w-7xl mx-auto px-8" >
284322 < div className = "text-center mb-16" >
285323 < h2 className = "text-5xl md:text-7xl font-bold mb-6 bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent" >
@@ -292,7 +330,12 @@ const PrinciplesValuesShowcase = () => {
292330
293331 { /* Principle Navigation */ }
294332 < div className = "flex justify-center mb-12" >
295- < div className = "flex gap-2 bg-muted/30 p-2 rounded-xl" >
333+ < div
334+ ref = { principlesNavRef }
335+ className = "flex gap-2 bg-muted/30 p-2 rounded-xl"
336+ onMouseEnter = { ( ) => setIsHovered ( true ) }
337+ onMouseLeave = { ( ) => setIsHovered ( false ) }
338+ >
296339 { translatedPrinciples . map ( ( principle , index ) => (
297340 < button
298341 key = { principle . id }
@@ -382,7 +425,7 @@ const PrinciplesValuesShowcase = () => {
382425 </ section >
383426
384427 { /* Values Section with Manual Slider */ }
385- < section className = "py-20" >
428+ < section ref = { valuesSectionRef } className = "py-20" >
386429 < div className = "max-w-7xl mx-auto px-8" >
387430 < div className = "text-center mb-16" >
388431 < h2 className = "text-5xl md:text-7xl font-bold mb-6 bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent" >
@@ -395,7 +438,12 @@ const PrinciplesValuesShowcase = () => {
395438
396439 { /* Value Navigation */ }
397440 < div className = "flex justify-center mb-12" >
398- < div className = "flex gap-2 bg-muted/30 p-2 rounded-xl" >
441+ < div
442+ ref = { valuesNavRef }
443+ className = "flex gap-2 bg-muted/30 p-2 rounded-xl"
444+ onMouseEnter = { ( ) => setIsHovered ( true ) }
445+ onMouseLeave = { ( ) => setIsHovered ( false ) }
446+ >
399447 { translatedValues . map ( ( value , index ) => (
400448 < button
401449 key = { value . id }
0 commit comments