mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
improved interface tab transitions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import type { TabbedContainerProps } from '../types/TabbedContainerProps';
|
||||
import { useSettingsContext } from '../SettingsContext';
|
||||
|
||||
@@ -21,6 +21,13 @@ const TabbedContainer: React.FC<TabbedContainerProps> = ({ tabs }) => {
|
||||
|
||||
const springTransition = { type: 'spring', stiffness: 250, damping: 25 };
|
||||
|
||||
const contentVariants = {
|
||||
hidden: { opacity: 0 },
|
||||
visible: { opacity: 1 },
|
||||
};
|
||||
|
||||
const fastOpacityTransition = { duration: 0.2 };
|
||||
|
||||
useEffect(() => {
|
||||
if (containerRef.current) {
|
||||
// @ts-expect-error for some reason its giving an error in TS but it works...
|
||||
@@ -67,14 +74,23 @@ const TabbedContainer: React.FC<TabbedContainerProps> = ({ tabs }) => {
|
||||
transition={springTransition}
|
||||
>
|
||||
<div className="absolute flex w-full" style={{ left: `${-position}%` }}>
|
||||
<AnimatePresence>
|
||||
{tabs.map((tab, index) => (
|
||||
<div
|
||||
activeTab === index && (
|
||||
<motion.div
|
||||
key={index}
|
||||
className={`w-full ${activeTab === index ? '' : 'hidden'}`}
|
||||
className="absolute w-full"
|
||||
initial="hidden"
|
||||
animate="visible"
|
||||
exit="hidden"
|
||||
transition={fastOpacityTransition}
|
||||
variants={contentVariants}
|
||||
>
|
||||
{tab.content}
|
||||
</div>
|
||||
</motion.div>
|
||||
)
|
||||
))}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user