GithubHelp home page GithubHelp logo

carousel's Introduction

CAROUSEL

I will describe steps of making component to make it easeir for reviewer

SETUP ENVIRONMENT

To start, let's create out project and run

yarn init

and accept default values.

Next, we'll try to set up dev devependies. Let's start with webpack. For this, let's install it:

yarn add webpack webpack-cli webpack-dev-server -D

For our project, we also need loaders :

yarn add style-loader css-loader sass sass-loader html-webpack-plugin -D

and, finally, let's install babel

yarn add @babel/core @babel/preset-env @babel/preset-react babel-loader -D

OK. Now let's deal with dependencies.

yarn add react react-dom.

Good. Now we'll set up webpack in webpack.config.js. Is wasn't very hard. Just follow the instructions of the official documentation.

Then. connect babel in .babelcrc. Made the same thing like we did with webpack. Follow official documentation.

Next. Create folder ./src and there make index.js, index.html, style.sass. Create basic !! markup in index.html, and add before closing tag

<script src="./index.js"></script>

All done. Now we can write our carousel.

Carousel was made as React component, which takes next props:

  • directly slides. It's array of objects with slide data. It can be either property set for building slides by pattern (it's not very bad idea, because we can get our slides from backend like json files, and easily transform them to react-components), either we can create absolutely any components and keep them in array, in order for them to be later transferred in Slide function, as Content property.
  • slidesCount. The count of slides, which will be shown in carousel chunk at a time.

So. In desktop version I created arrow buttons to change carousel slide. In mobile version changing change is foreseen by swiping.

I am facing a pretty big problem when did the infinite scroll functionality. Without it, task would be much more easier.

Ultimately, I decided to generate three <div> elements for each change in the current frame. Previous, current and next chunk. As for me, it works not bad.

Sorry, I have not been able to do the implementation of the transition to the current chunk well enough due to the lack of time, since I work and I have children, and there is not much free time. I don’t want to keep you waiting long enough, but I am sure I can do everything perfectly. If you look and want me to do better please let me know.

deploy

video

carousel's People

Contributors

esoshyki avatar

Watchers

 avatar

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.