React Native Animated Tabs & Animated Indicator using FlatList

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • 🔥 Create a React Native Animated Tabs indicator / Dynamic Tabs indicator that will dynamically change its width and position based on React Native FlatList scrollX.
    In this video tutorial we'll learn how to create:
    - learn how to create an animated tabs using React Native FlatList
    - learn how to animate a tabs indicator
    - learn how to create an animated tabs indicator using Animated API
    - learn how to measureLayout and use React Native findNodeHandle
    Built using @expo, vanilla React Native Animated API and FlatList.
    This code works in plain React Native project as well since we are using only React Native APIs such as Animated and FlatList in order to create a React Native Animated Tabs and Animated tabs indicator that will scale and position according to the active slide from the FlatList.
    ----
    ⚠️ Access full source code: www.patreon.com/bePatron?u=20...
    ----
    Starter code: gist.github.com/catalinmiron/...
    👉👉 Have any questions? Join Discord: / discord .
    Want to support me?
    - Patreon: / catalinmiron
    - BuyMeACoffee: www.buymeacoffee.com/catalinm...
    - Paypal: paypal.me/catalinmiron
    ----
    You can find me on:
    - Github: github.com/catalinmiron
    - Twitter: / mironcatalin
    - Website: batman.codes
    Timeline:
    00:00 Introduction + What we’re going to build
    00:56 Boilerplate + starter code link
    02:19 Create the Animated FlatList
    05:15 Create Animated.Value ref for FlatList
    06:20 Create Tabs component
    07:10 Create Tab component
    09:30 Create Tabs Indicator component
    10:30 Get the Tabs measurements using measureLayout and findNodeHandle
    12:40 How React Native ref measureLayout works
    16:50 Animated Indicator width and x based on FlatList scrollX position
    20:10 Last part, press on tab to modify FlatList scrollOffset
    23:14 Final words and thanks
    #react-native-tabs #react-native-flatlist #react-native-tabs-animation #react-native-dynamic-underline-animation #react-native-animated-tabs-indicator

ความคิดเห็น • 226

  • @mpeguese210
    @mpeguese210 ปีที่แล้ว

    @Catalin This tutorial helped me complete revamp a project I was working on. Thanks for much man for all the Support you give the RN Community.

  • @npc73x
    @npc73x 2 ปีที่แล้ว +1

    Such a valuable content,that go through multiple steps, keep doing your awesome work

  • @jamieblair4336
    @jamieblair4336 3 ปีที่แล้ว +3

    Not all heroes wear capes.
    Thank you Catalin for an awesome tutorial.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad it was helpful! Hat down Jamie ✌️

  • @hwj8640
    @hwj8640 2 ปีที่แล้ว

    Amazing video, I really enjoy your tutorial. You explain everything very well.

  • @amanmittal416
    @amanmittal416 3 ปีที่แล้ว +3

    This video has the best intro I've ever seen (*the sideways head tilt part!*) 🎃

  • @GuperGER
    @GuperGER 3 ปีที่แล้ว +4

    Wow! This is looking awesome!
    I'm currently working in Xamarin Forms but after watching some of your videos I can definately see me trying out React Native :)
    Keep it up! :)

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thanks a lot, I’m glad you found it useful ✌️ Thanks Vicent!

  • @techienomadiso8970
    @techienomadiso8970 3 ปีที่แล้ว +9

    My guy, the world needs to know of you. Your content is quality. People are missing out if they don't know this channel

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thank you so much Francis for showing your appreciation, it means a lot to me ✌️

    • @optimusdebugger9638
      @optimusdebugger9638 3 ปีที่แล้ว

      just discovered him but he's dropping some bomb

  • @pradeepthite2894
    @pradeepthite2894 หลายเดือนก่อน

    Brother you are awesome. You explained very well. I love your explain style.

  • @collocheru
    @collocheru 3 ปีที่แล้ว +1

    This is incredible and the explanations of the steps is super helpful, great video 🙏

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad it was helpful! Thank you Cheruiyot! ✌️

  • @shareef2178
    @shareef2178 3 ปีที่แล้ว

    I rarely subscribe to channels but this channel is worth to subscribe to, thanks a lot for your hard work, keep it up, I love your content.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thank you so much Syarif! It means a lot to me ✌️

  • @erlanakylbekovich4586
    @erlanakylbekovich4586 3 ปีที่แล้ว

    I really liked your videos. More of these videos. This part of awesome!

  • @cli23
    @cli23 3 ปีที่แล้ว

    Great stuff as always, Catalin!

  • @facundofernandez1144
    @facundofernandez1144 3 ปีที่แล้ว +1

    Your videos are excellent, thank you very much for sharing this content. I am always waiting for the next one to learn more. Greetings from Argentina.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thanks a lot, I’m glad you found it useful ✌️ Thanks Facundo ✌️

  • @619dixitrock
    @619dixitrock 3 ปีที่แล้ว

    Really helpful content. I didn't find any good content in TH-cam for react native Animations. This one really is interesting and got lot of information.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thanks for sharing your feedback Dixit. I’m glad you found my videos useful ✌️

  • @haightgao2389
    @haightgao2389 หลายเดือนก่อน

    Thank you for sharing such a great tutorial.

  • @aftabamin8508
    @aftabamin8508 3 ปีที่แล้ว

    thanks, dude. you have made my life easier with these great tutorials. love from Pakistan. if I get a chance I will meet you in my life.

  • @anshul9856
    @anshul9856 2 ปีที่แล้ว

    Very helpful video! Makes me happy to know such smart people are in the same field as me :)

  • @re.liable
    @re.liable 3 ปีที่แล้ว

    That was freaking awesome!

  • @prakashd842
    @prakashd842 3 ปีที่แล้ว +15

    Thanks for sharing such a valuable content , we are thankful

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      So nice of you! Thanks Prakash! ✌️

    • @faizanansari975
      @faizanansari975 3 ปีที่แล้ว

      @@CatalinMironDev i have a share a small video on ur Twitter handle please check the dm n plz make a video by achieving that in react native flatlist

  • @wom987
    @wom987 3 ปีที่แล้ว

    Amazing tutorial bruh! you got a new sub!

  • @yakupdurmus3008
    @yakupdurmus3008 ปีที่แล้ว

    Thanks for this tutorial ! Nice content

  • @HOWGLAI
    @HOWGLAI 2 ปีที่แล้ว

    Thank you MAN! That`s amazing

  • @usamaali736
    @usamaali736 3 ปีที่แล้ว

    another excellent and insightful video as always!

  • @radomirmijovic2605
    @radomirmijovic2605 ปีที่แล้ว

    Thanks man! Great video

  • @darianaorlova2405
    @darianaorlova2405 3 ปีที่แล้ว

    This is very useful for me video, thank you. You're cool.

  • @mclovin_2475
    @mclovin_2475 หลายเดือนก่อน

    gracias capo ,saludos desde argentina(el mejor pais del mundo hermano)

  • @capy7773
    @capy7773 3 ปีที่แล้ว

    You're awesome, I like your content. Keep going!

  • @TaiBradCDinh
    @TaiBradCDinh 2 ปีที่แล้ว

    amazing job man, thanks a lot

  • @tinpham1052
    @tinpham1052 3 ปีที่แล้ว +1

    perfect bro, please create more video :D

  • @Pupu._
    @Pupu._ 2 ปีที่แล้ว

    it's difficult for me I really should repeat watching it . thank you for the amazing video !!

  • @riccardomirarchi4136
    @riccardomirarchi4136 3 ปีที่แล้ว

    you are doing great man! thanks so much, love your contents

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad you like them! Cheers Riccardo! ✌️

  • @Amitk7950
    @Amitk7950 3 ปีที่แล้ว

    Thanks for making good stuff, learning from your tutorial 👍

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thanks a lot Amit, I’m glad you found it useful ✌️

  • @mausambhalekar1378
    @mausambhalekar1378 3 ปีที่แล้ว

    Sir you are amazing thank you so much

  • @ludwigvillalba1886
    @ludwigvillalba1886 2 ปีที่แล้ว

    Thanks for sharing!

  • @ehtishamtahir2187
    @ehtishamtahir2187 2 ปีที่แล้ว

    Amazing man...
    You are awesome

  • @minotuki100
    @minotuki100 3 ปีที่แล้ว +3

    Hey Catalin. Thanks for this tuto! Your method with forwardRef is so useful and I feel better to use functionals components with Animated than the class components. I added myself the challenge to have useNativeDriver:true. For that, I use scaleX instead of width. I share here the new scrollX interpolations :
    const scaleX = scrollX.interpolate({
    inputRange,
    outputRange: measures.map((item, i) =>
    i > 0 ? item.width / measures[0].width : 1
    ),
    });
    const translateX = scrollX.interpolate({
    inputRange,
    outputRange: measures.map(
    (item, i) => item.x + item.width / 2 - measures[0].width / 2
    ),
    });
    And new styles for the Animated.View are :
    width: measures[0].width,
    transform: [{ translateX }, { scaleX }],

    • @sunnymittal1906
      @sunnymittal1906 2 ปีที่แล้ว +2

      A slightly simpler way to do this might be as follows:
      const indicatorWidth = scrollX.interpolate({
      inputRange,
      outputRange: measures.map((measure) => measure.width),
      }); // Same as video
      const translateX = scrollX.interpolate({
      inputRange,
      outputRange: measures.map((measure) => measure.x + measure.width / 2),
      }); // mostly the same but adding measure.width / 2 to compensate for how scaling works
      Then the changed indicator style would just be:
      width: 1,
      transform: [{ translateX }, { scaleX }],

  • @thenriquedb
    @thenriquedb 4 หลายเดือนก่อน

    Awesome content!

  • @ed3osp
    @ed3osp 2 ปีที่แล้ว

    Awesome job

  • @sinaebr7337
    @sinaebr7337 3 ปีที่แล้ว

    wonderful. thanks Man also thank you for putting starter code.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      You’re welcome! I’m listening to your feedback and this is what came a lot, to add the starter code. Thanks Sina ✌️

  • @mirzairshad4063
    @mirzairshad4063 3 ปีที่แล้ว

    Wooww what a creative work bro thank you very very much hero of my life

  • @philipprajahmourasrivastav2398
    @philipprajahmourasrivastav2398 3 ปีที่แล้ว +14

    Amazing video, thank you so much for shedding light on how some basic animations work. One thing that I however ran into was the the indicator wouldn't show up until it did a hot reload. Whenever I would run the app from scratch the indicator wouldn't be there. I found this to be because ref.current.measureLayout was initially returning 0 for all of the values. I'm not sure why but if anyone else runs into this my solution was to put the ref.current in the array at the end of the useEffect. This essentially makes sure that useEffect runs again whenever ref.current changes (like a component will update). Hope this helps someone. Thanks again! Also video suggestion from me would be a collapsible view that collapses when you begin scrolling a list below it.

    • @DaveBatistaa
      @DaveBatistaa 3 ปีที่แล้ว

      Thank you so much, Sir!

    • @angNguyen-cg8gk
      @angNguyen-cg8gk 2 ปีที่แล้ว

      can you please help me, in this case what exactly "the ref.current"

    • @shafqatullah6666
      @shafqatullah6666 2 ปีที่แล้ว

      @@angNguyen-cg8gk same here...
      no value "[object Object],[object Object],[object Object],[object Object],[object Object]"

    • @cuongnguyen1230
      @cuongnguyen1230 2 ปีที่แล้ว

      Thank you, a lot...

    • @BDCCNVUONGANKHANG
      @BDCCNVUONGANKHANG 8 หลายเดือนก่อน

      thanks you so much bro, my problem is same. I fixed it, yeah

  • @annhienofficial8000
    @annhienofficial8000 3 ปีที่แล้ว

    what a great tutorial

  • @sarahali-wn5sd
    @sarahali-wn5sd 3 ปีที่แล้ว

    Can you please do a page curl flip animation like ebooks? Thaanks for the amazing tutorials btw!

  • @kasraafshari4293
    @kasraafshari4293 3 ปีที่แล้ว

    Hey man you are amazing! thank's for your awesome videos!

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thank you Kasra, I’m happy that you found them useful. ✌️

  • @PrakashChAwal
    @PrakashChAwal 3 ปีที่แล้ว

    Nice content !! Can you make a basic understanding of the react-native reanimated series?

  • @Alijanadeli
    @Alijanadeli 3 ปีที่แล้ว

    Hi, Thankyou for wonderfull content!

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad you enjoy it! Thanks Alijan ✌️

  • @luispaulo5714
    @luispaulo5714 3 ปีที่แล้ว

    Hey this is awesome. i learned so much with you. thank you so much for give me with billions of ideas.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      You’re more than welcome and I’m happy that you found the videos inspiring. Sharw what you’re building with us, you can join the discord, there’s a dedicated channel for sharing code there. Thanks Luis ✌️

    • @luispaulo5714
      @luispaulo5714 3 ปีที่แล้ว

      Yeah! i want to code some UI clone using your content about shared element and animations.
      How can i find you on linkedin to quote you there about teachings?
      Thanks man!

  • @DeCodewithMinte
    @DeCodewithMinte 3 ปีที่แล้ว

    Awesome tutorial very helpful

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thanks a lot, I’m glad you found it useful ✌️

  • @rosoonbphingkhue205
    @rosoonbphingkhue205 2 ปีที่แล้ว

    Thanks a lot 👍👍👍👍👍

  • @Jitsandcrypto
    @Jitsandcrypto 3 ปีที่แล้ว

    Beautiful

  • @mytube5182
    @mytube5182 3 ปีที่แล้ว

    Cool..you are awsome dude..

  • @nguyennam6774
    @nguyennam6774 2 ปีที่แล้ว +1

    Thanks alot for your sharing. I follow your guides up to push(x,y,width,height) after measureLayout to above array then i got empty.
    I cannot put to that array so cannot setstate

  • @duxuan4957
    @duxuan4957 3 ปีที่แล้ว

    "Cảm ơn" - Thank you.
    "Rất hữu ích" - Very useful

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      "Cảm ơn" ✌️

    • @duxuan4957
      @duxuan4957 3 ปีที่แล้ว

      @@CatalinMironDev I think I and many RNers are looking forward to Ripple Effect of Material Design Buttons for both ios and android.
      Was it too difficult for you?

  • @deepakchoudhary3066
    @deepakchoudhary3066 2 ปีที่แล้ว

    Awesome work, Just if i want to change the active tab text color as well how can i do that ?

  • @carlosandresafanadorcabal2801
    @carlosandresafanadorcabal2801 2 ปีที่แล้ว

    this is gold

  • @cuongnguyen1230
    @cuongnguyen1230 2 ปีที่แล้ว

    Great video!
    How can I change the text color? Did you have any idea about it?

  • @thesage86
    @thesage86 3 ปีที่แล้ว +2

    Hey Amazing tutorial man
    I'm on a project in which I'm using hashmap instead of array of images
    So, Will hashmap work in place of arrayin Flatlist section ??
    plus what is the font u r using in VSCode ??

  • @johnny719top
    @johnny719top 3 ปีที่แล้ว

    very good video!!

  • @andrzejhanusek7749
    @andrzejhanusek7749 3 ปีที่แล้ว

    Great stuff!

  • @skippybassmaster7268
    @skippybassmaster7268 2 ปีที่แล้ว

    As usual love your content.
    I'm looking for a way to do exactly this, but where the tabs are scrollable. I'm having hard time to find the active index tab position to scroll my indicator to the right spot.
    Any idea ?

  • @gabrr
    @gabrr 3 ปีที่แล้ว

    Awesome content bro

  • @sukhvindersingh6185
    @sukhvindersingh6185 3 ปีที่แล้ว

    Awsome man!

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad you think so! Thanks Sukhvinder! ✌️

  • @zouletterider4797
    @zouletterider4797 2 ปีที่แล้ว

    hi thank for the tutorial, is it possible to add lazy load on such tabs ?

  • @4hiphop1
    @4hiphop1 ปีที่แล้ว

    Man you are top

  • @fixocsolutions2695
    @fixocsolutions2695 3 ปีที่แล้ว +1

    can i use scrollview instead of row in tabs
    and measure width and x of childs

  • @mehdiamiri5418
    @mehdiamiri5418 2 ปีที่แล้ว

    hey Catalin thank you for your great video but i have a problem.indicator behaves so bad when tab items increases. you used .map for rendering tab titles but i changed it to flatlist because i have 8 tab titles. after that when i swipe to other tab , indicator position completely treats wrong

  • @furkanturkylmaz8385
    @furkanturkylmaz8385 3 ปีที่แล้ว

    Perfect bro

  • @koushiksaha3511
    @koushiksaha3511 หลายเดือนก่อน

    Hi @Catalin, thank you for your tutorial .. I'm facing a problem like at first rendering indicator is not showing .. can you please resolve this issue?

  • @thenoob8682
    @thenoob8682 ปีที่แล้ว

    awsome... thank you man. I tried it . unfortunately my TabIndicator not rendering on the first time. but if I refresh the screen it appears.

    • @nathan8541
      @nathan8541 ปีที่แล้ว

      Put containerRef.current in the array at the end of the useEffect

  • @KROMMASyS
    @KROMMASyS ปีที่แล้ว

    Awesome

  • @marchabib8168
    @marchabib8168 2 ปีที่แล้ว

    Hello ! Amazing vidéo !
    I just have one question : You imported "findNodeHandle" but never used it. What is this for ?

  • @waqasehmed
    @waqasehmed 3 ปีที่แล้ว

    man you gem ;heart

  • @Eddysapata
    @Eddysapata 3 ปีที่แล้ว

    Love you

  • @aqdasilyas2768
    @aqdasilyas2768 3 ปีที่แล้ว

    Amazing video brother ... One thing I want to ask that how can I change different components instead of different images on background ... In this video, when i click specific text it appears image related to that text.... But now I want that when i click on specific text... it shows a component instead of image ... how can i doo that ? please answer me as soon as possible because it helps me in my project

  • @sidilain5533
    @sidilain5533 3 ปีที่แล้ว

    Can you done this with react Viewpager? that component only exposes onPageScroll property, instead onScroll, greetings from México.

  • @animeshsrivastava1159
    @animeshsrivastava1159 3 ปีที่แล้ว

    Hi, really like your videos.
    Is it possible to have a dynamic react component for each tab in place of the image?
    Meaning different ( varying in tags ) structure for each of the tabs rather than having an image?

    • @sunnymittal1906
      @sunnymittal1906 2 ปีที่แล้ว

      The only thing governing the dimensions of the component (currently an image) is the outer ...you can put anything inside it

  • @BehindTheIssues
    @BehindTheIssues 3 ปีที่แล้ว

    Hi Catalin, grate job, please make tabs scrollable

  • @filouledoux
    @filouledoux 3 ปีที่แล้ว

    Great video! Quick question, why not use the new Pressable component?

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Great suggestion, I’ll do it in the next videos. Thanks ✌️

  • @andreaintech4305
    @andreaintech4305 3 ปีที่แล้ว +2

    Hi! Thank you so much for your videos. I have a question: where did you use 'findNodeHandle'?

    • @call_me_rusker
      @call_me_rusker ปีที่แล้ว +1

      I had the same question…😮

  • @AhmedAb96
    @AhmedAb96 3 ปีที่แล้ว

    Thank you so much.
    If u can make a video about how to make coustom tabBar animated with react-navigation 5 please.
    I wish u the the best .

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Great suggestion. Thanks Ahmed ✌️

  • @vigneshwaraneswaramoorthi4117
    @vigneshwaraneswaramoorthi4117 3 ปีที่แล้ว

    Any performance issue will happen, when I create ref for each array item?

  • @__edward
    @__edward 2 ปีที่แล้ว

    How do I disable the swipe gesture? I want to only scroll on the tab press.

  • @romankoncek150
    @romankoncek150 2 ปีที่แล้ว

    Good job, few things I'd do differently.
    1. Using onLayout prop for measurements instead all of these refs would make it more simple
    2. You could use scaleX transformation instead of width so you can use native driver to have better performance
    3. It is not possible to set the animation duration when pressing tabs, because scrollToOffset method does not support it. I guess the only way to solve this is to basically implement the scroling by yourself which is a lot of effort.

    • @amisckass9550
      @amisckass9550 2 ปีที่แล้ว

      How I can do it with onLayout share with us code source?

  • @Sara-po1jd
    @Sara-po1jd 11 หลายเดือนก่อน +1

    in your indictator you are doing this
    const indicatorWidth = scrollX?.interpolate({
    inputRange,
    outputRange: measures.map((measure) => measure.width),
    });
    const translateX = scrollX?.interpolate({
    inputRange,
    outputRange: measures.map((measure) => measure.left),
    });
    What I would l. iketo do is to use the useAnimatedStyle instead , Iam using teh Animated imported from react-native-reanimated.. any suggestion?

  • @akashraj4901
    @akashraj4901 2 ปีที่แล้ว

    Can you please tell me how to make the tabs horizontally scrollable?

  • @NonSense1311
    @NonSense1311 ปีที่แล้ว

    What about multi columns/pages by flatlist and dots indicator?

  • @tahashaikh1733
    @tahashaikh1733 2 ปีที่แล้ว

    how do you scroll these tabs for active slide if it is more thn 5 ?

  • @iblisalaleab4241
    @iblisalaleab4241 2 ปีที่แล้ว

    Hi, really like your videos. This is awesome.
    However, I'm really struggling with this error
    TypeError: _ref$current.scrollToOffset is not a function. (In' _ref$current.scrollToOffset({
    offset: itemIndex * width,
    })','_ref$current.scrollToOffset' is undefined ).
    Thank you very much in advance.

  • @feritejakusuma8450
    @feritejakusuma8450 3 ปีที่แล้ว

    Thanks for the amazing tutorial. i'm new in .JS and i learned a lot from your video,
    and i wanna ask, at 21:12 . what is ( ref?.current?.scrollToOffset({....}) ) mean ? , why there is question mark there ?

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +2

      Hi Feri, great question and sorry for missing this out in my explanation.
      The question mark it’s called optional chaining (developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) and is checking if the left hand side exists otherwise returns undefined.
      Eg:
      if(obj && obj.key && obj.key.subKey)
      Can be translated to
      obj?.key?.subKey
      Thanks and I hope that this was helpful. ✌️

  • @newtonsazzad748
    @newtonsazzad748 ปีที่แล้ว

    where did you use the findNodeHandle?

  • @oriarazi
    @oriarazi 3 ปีที่แล้ว

    Thanks!
    How can I actually know which one is shown ? I want to make the current shown tab’s header bold and the rest normal

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Hi, check my latest video, I'm explaining there how to get the active slide index. Thanks ✌️

  • @oscar_cornejo
    @oscar_cornejo 3 ปีที่แล้ว +1

    👏🏼👏🏼🔥

  • @plataformameugym
    @plataformameugym 3 ปีที่แล้ว

    what font you used in vscode?

  • @pascalkollie4216
    @pascalkollie4216 2 ปีที่แล้ว +1

    If you want to change the color of the tab with a swipe you can do this const
    Indicator = ({ measures, scrollX, dataValues }) => {

    const inputRange = dataValues.map((_, i) => i * width)
    const IndicatorWidth = scrollX.interpolate({
    inputRange,
    outputRange: measures.map((measure) => measure._width)

    })
    const translateX = scrollX.interpolate({
    inputRange,
    outputRange: measures.map((measure) => measure.x)
    })

    const colors = scrollX.interpolate({
    inputRange,
    outputRange: ["gray", "red", "blue"]
    })

    return
    }

  • @amilalisahil6882
    @amilalisahil6882 2 ปีที่แล้ว

    which font are you using

  • @narencool236
    @narencool236 2 หลายเดือนก่อน

    How you got that font in vscode?

  • @samidebayroune3478
    @samidebayroune3478 ปีที่แล้ว

    can we do it with components instead of flatlist ?

  • @hosamashraf8083
    @hosamashraf8083 3 ปีที่แล้ว +1

    Thanks for sharing this. Can I ask why didn't you use the onLayout prop of a View to calculate the view measurements?

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Because I wanted to get the measurements based on the parent container. Thanks ✌️

    • @hosamashraf8083
      @hosamashraf8083 3 ปีที่แล้ว

      Catalin Miron onLayout also gives the measurements based on parent view right? Pardon me if I'm wrong.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +2

      @@hosamashraf8083 you are right measureLayout and onLayout give you back the same thing, but onLayout it’s a method that exists in the children and I wanted to have access to children from the parent via ref. Ref is more powerful for this example. Thanks ✌️

    • @hosamashraf8083
      @hosamashraf8083 3 ปีที่แล้ว

      @@CatalinMironDev Thanks for the explaining. 🙌

  • @attran7775
    @attran7775 3 ปีที่แล้ว

    Can I scroll horizontal tabs bar?

  • @isidorsajinovic5573
    @isidorsajinovic5573 3 ปีที่แล้ว +2

    Hey man! Excellent job!
    I have one bug here. My measurement is done before render and when I start my app indicator never shows up because measurements are always zero (x, y, width and height are zero). When I remove [ ] in useEffect hook it works but it isn't smooth. Do you have any idea how to solve that?