Giter Club home page Giter Club logo

cardshiftanimation's Introduction

Hi there ๐Ÿ‘‹

I'm Dan! A software engineer based out of Toronto who is passionate about React, React-Native, Native iOS with Swift and pretty much anything front end ๐Ÿ˜„.

This is my GitHub page with all the examples I write for my YouTube Videos โค๏ธ.

  • ๐Ÿ”ญ Iโ€™m currently working on React-Native at Shopify!
  • ๐ŸŽฅ Making Videos about anything and everything React-Native ๐Ÿ™‚
  • ๐ŸŽฎ Playing mediocre Tekken 8 ๐ŸฅŠ

While you're here feel free to check out some of my blog articles ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป

Currently working with

My Skills

Previously worked with

My Previous Skills

Connect with me!

cardshiftanimation's People

Contributors

friyiajr avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cardshiftanimation's Issues

Example with more than 3 Cards

Hi there,

first of all thanks for your video. It inspired me to integrate your code into my project. Unfortunately, I am running into an issue when dealing with the case of more that 3 cards. For example, when the cards are coming from the backend and you only know the length of the array. Obviously, you cannot create unlimited useSharedValues() for firstPriority, secondPriorty (...nPriority).

So I tried to create an array with priorities rather than initiating each useSharedValue. It works pretty smooth, but it does not seem to update the parent component when I am in the .onEnd() function of the gesture.Pan() domain.

Do you know where the issue could be ?

Keep up the great work :)

`const { height, width } = Dimensions.get("screen");

interface CardContainerProps {
id: number;
name: string;
priorities: SharedValue<number[]>;
priority: number;
}

const CardContainer: FC = ({ id, name, priority, priorities }) => {

const BOTTOM_BUFFER = 30;

const yTranslation = useSharedValue(BOTTOM_BUFFER);

const gesture = Gesture.Pan()
.onBegin(({ translationY }) => {
yTranslation.value = translationY + BOTTOM_BUFFER;
})

.onUpdate(({ translationY }) => {
  yTranslation.value = translationY + BOTTOM_BUFFER;
})
.onEnd(() => {
  let currentPrioritites = priorities.value;

  console.log("Before", priorities.value);

  const lastItem = currentPrioritites[currentPrioritites.length - 1];

  for (let i = currentPrioritites.length - 1; i > 0; i--) {
    currentPrioritites[i] = currentPrioritites[i - 1];
  }

  currentPrioritites[0] = lastItem;

  priorities.value = currentPrioritites;

  console.log("After", priorities.value);

  yTranslation.value = withTiming(BOTTOM_BUFFER, {
    duration: 400,
  });
});

const style = useAnimatedStyle(() => {
return {
position: "absolute",
width: 325,
height: 200,
bottom: 100 - priority * 35,
borderRadius: 20,
zIndex: priority * 100,
backgroundColor: "#fff",
transform: [
{
translateY: yTranslation.value,
},
],
};
});

return (



);
};

const Projects: React.FC = (props: Props) => {
const data = [
{
id: 1,
name: "Name 1 ",
},
{
id: 2,
name: "Name 2",
},
{
id: 3,
name: "Name 3",
},
];

const priorities = useSharedValue<number[]>([0, 1, 2]);

return (


{data.map((d, i) => (

))}


);
};
export default Projects;

const styles = StyleSheet.create({
root: {
flex: 1,
},
flatList: {
marginTop: height * 0.1,
},
container: {
flex: 1,
alignItems: "center",
},
});
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.