React Pagination
How do I make an react pagination?
React paginator/carousel. What is a react pagination? How do you make a react pagination? This script and codes were developed by Veronika on 30 November 2022, Wednesday.
React Pagination - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Pagination</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react-with-addons.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
React Pagination - Script Codes CSS Codes
body { background-color: #323232;
}
.container { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -ms-flex-wrap: nowrap; flex-wrap: nowrap; height: 350px; width: 450px; margin: 20px auto;
}
.animation-container { -webkit-box-flex: 1; -ms-flex: 1 1 auto; flex: 1 1 auto; position: relative; height: 100%; overflow: hidden; border: 4px solid gainsboro;
}
.item { box-sizing: border-box; position: absolute; width: 100%; height: 100%;
}
.paginator-button { background: none; padding: 0; width: 0; height: 0; border: 0; margin: 10px; cursor: pointer; color: gainsboro;
}
.paginator-button:focus { outline: 0;
}
.paginator-button:hover { color: #c8c8c8;
}
.paginator-button--left { border-top: 24px solid transparent; border-bottom: 24px solid transparent; border-right: 24px solid;
}
.paginator-button--right { border-top: 24px solid transparent; border-bottom: 24px solid transparent; border-left: 24px solid;
}
/* --- PAGING TRANSITIONS --- */
.forwards-enter.forwards-enter-active, .forwards-leave, .backwards-enter.backwards-enter-active, .backwards-leave { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); -webkit-transition: -webkit-transform 600ms ease-in-out; transition: -webkit-transform 600ms ease-in-out; transition: transform 600ms ease-in-out; transition: transform 600ms ease-in-out, -webkit-transform 600ms ease-in-out;
}
.forwards-leave.forwards-leave-active, .backwards-enter { -webkit-transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0);
}
.forwards-enter, .backwards-leave.backwards-leave-active { -webkit-transform: translate3d(100%, 0, 0); transform: translate3d(100%, 0, 0);
}
React Pagination - Script Codes JS Codes
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var animationSpeed = 600; //needs to be in sync with the animation-speed in css file
var COLORS = { MIDNIGHT: 'rgba(122, 48, 108, 1)', BLUE_LAGOON: 'rgba(169, 228, 239, 1)', FRENCH_LIME: 'rgba(150, 245, 80, 1)', GRAY_BLUE: 'rgba(142, 141, 190, 1)', LIGHT_GREEN: 'rgba(129, 244, 149, 1)'
};
var Page = function (_React$Component) { _inherits(Page, _React$Component); function Page() { _classCallCheck(this, Page); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Page.prototype.componentWillUnmount = function componentWillUnmount() { this.props.onComponentWillUnmount(); }; Page.prototype.render = function render() { return React.createElement('div', { className: 'item', style: { backgroundColor: this.props.color } }); }; return Page;
}(React.Component);
var PaginatorArrow = function (_React$Component2) { _inherits(PaginatorArrow, _React$Component2); function PaginatorArrow() { _classCallCheck(this, PaginatorArrow); return _possibleConstructorReturn(this, _React$Component2.apply(this, arguments)); } PaginatorArrow.prototype.render = function render() { var className = "paginator-button paginator-button--" + this.props.arrowDirection; return React.createElement('button', { className: className, onClick: this.props.clickHandler }); }; return PaginatorArrow;
}(React.Component);
var Container = function (_React$Component3) { _inherits(Container, _React$Component3); function Container() { _classCallCheck(this, Container); var _this3 = _possibleConstructorReturn(this, _React$Component3.call(this)); _this3.state = { currentItem: 0, direction: 'forwards', preventClickEvents: false, colors: [].concat(Object.values(COLORS)) }; _this3.moveToNextItem = _this3.moveToNextItem.bind(_this3); _this3.moveToPreviousItem = _this3.moveToPreviousItem.bind(_this3); _this3.resetClickEvents = _this3.resetClickEvents.bind(_this3); return _this3; } Container.prototype.render = function render() { var currentItemIndex = this.state.currentItem; return React.createElement( 'div', { className: 'container' }, React.createElement(PaginatorArrow, { arrowDirection: 'left', clickHandler: this.moveToPreviousItem }), React.createElement( 'div', { className: 'animation-container' }, React.createElement( ReactCSSTransitionGroup, { transitionName: this.state.direction, transitionEnterTimeout: animationSpeed, transitionLeaveTimeout: animationSpeed }, React.createElement(Page, { key: currentItemIndex, currentItem: currentItemIndex, color: this.state.colors[currentItemIndex], onComponentWillUnmount: this.resetClickEvents }) ) ), React.createElement(PaginatorArrow, { arrowDirection: 'right', clickHandler: this.moveToNextItem }) ); }; Container.prototype.moveToNextItem = function moveToNextItem() { if (this.state.preventClickEvents) { return; } var nextItem = this.state.currentItem + 1; if (nextItem >= this.state.colors.length) { nextItem = 0; } this.setState({ direction: 'forwards', currentItem: nextItem, preventClickEvents: true }); }; Container.prototype.moveToPreviousItem = function moveToPreviousItem() { if (this.state.preventClickEvents) { return; } var nextItem = this.state.currentItem - 1; if (nextItem < 0) { nextItem = this.state.colors.length - 1; } this.setState({ direction: 'backwards', currentItem: nextItem, preventClickEvents: true }); }; Container.prototype.resetClickEvents = function resetClickEvents() { this.setState({ preventClickEvents: false }); }; return Container;
}(React.Component);
ReactDOM.render(React.createElement(Container, null), document.body);
Developer | Veronika |
Username | ivhed |
Uploaded | November 30, 2022 |
Rating | 3 |
Size | 5,354 Kb |
Views | 18,216 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
SVG Snowflakes | 2,929 Kb |
CSS Baby | 1,923 Kb |
FreeCodeCamp - Tic Tac Toe Game | 4,469 Kb |
Space Game Button | 3,321 Kb |
CSS Course - Fluid layout | 2,740 Kb |
FreeCodeCamp - Twitch.tv | 3,285 Kb |
Background blend mode | 1,610 Kb |
FreeCodeCamp - Personal Portfolio | 3,262 Kb |
FreeCodeCamp - Local Weather | 3,926 Kb |
CSS Course - Build-a-Kitty Workshop | 3,183 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Transition | Shayhowe | 1,632 Kb |
Scoreboard.js basic usage | Tbleckert | 1,733 Kb |
Pruebas de d3.js | Juanmanuelcarnerero | 2,485 Kb |
A Pen by Jonas Bjork | Jonasbjork | 3,115 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
Price Comparison Table | Orrinward | 3,459 Kb |
Vanilla JS - A toggleClass function | Woodwork | 2,532 Kb |
Cloudy Spiral CSS animation | Hakimel | 6,587 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
SVG Hover Animations | Kjbrum | 10,557 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!