Skip to content

Commit

Permalink
fix bug in demo app, update Readme and change version to 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyshlyaev177 committed Jul 24, 2018
1 parent d9e9454 commit 24f0c79
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

[![Build Status](https://travis-ci.org/asmyshlyaev177/react-horizontal-scrolling-menu.svg?branch=master)](https://travis-ci.org/asmyshlyaev177/react-horizontal-scrolling-menu)
[![Coverage Status](https://coveralls.io/repos/github/asmyshlyaev177/react-horizontal-scrolling-menu/badge.svg?branch=master)](https://coveralls.io/github/asmyshlyaev177/react-horizontal-scrolling-menu?branch=master)
[![npm](https://img.shields.io/npm/v/react-horizontal-scrolling-menu.svg)](https://www.npmjs.com/package/react-horizontal-scrolling-menu)
[![codebeat badge](https://codebeat.co/badges/2457d520-3d0f-4f70-b563-842d9574ebc6)](https://codebeat.co/projects/github-com-asmyshlyaev177-react-horizontal-scrolling-menu-master)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=asmyshlyaev177%40gmail%2ecom&lc=US&item_name=asmyshlyaev177&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)

[Demo](https://asmyshlyaev177.github.io/react-horizontal-scrolling-menu)

Expand Down Expand Up @@ -179,4 +182,4 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
| :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-horizontal-scrolling-menu": "^0.1.4",
"react-horizontal-scrolling-menu": "^0.1.5",
"react-scripts": "1.1.4"
},
"scripts": {
Expand Down
15 changes: 10 additions & 5 deletions examples/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const list = [
{ name: 'item17' },
{ name: 'item18' },
{ name: 'item19' },
{ name: 'item20' }
{ name: 'item20' },
{ name: 'item21' },
{ name: 'item22' },
{ name: 'item23' },
{ name: 'item24' },
{ name: 'item25' }
];

const MenuItem = ({ text, selected }) => {
Expand Down Expand Up @@ -82,15 +87,15 @@ class App extends Component {

onSelect = key => {
console.log(`onSelect: ${key}`);
this.setState({ selected: key });
}

componentDidUpdate(prevProps, prevState) {
const { alignCenter, wheel } = prevState;
const { alignCenter } = prevState;
const {
alignCenter: alignCenterNew,
wheel: wheelNew
alignCenter: alignCenterNew
} = this.state;
if (alignCenter !== alignCenterNew || wheel !== wheelNew) {
if (alignCenter !== alignCenterNew) {
this.menu.setState({ translate: 0, initialized: true, mounted: true, xPoint: 0});
this.menu.setInitial();
this.menu.forceUpdate();
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-horizontal-scrolling-menu",
"version": "0.1.4",
"version": "0.1.5",
"description": "Scrolling horizontal menu component for React, support mouse and touch devices.",
"esnext": "src/index.js",
"browser": "build/index.js",
Expand All @@ -10,7 +10,9 @@
"test": "jest --coverage --runInBand --ci",
"postbuild": "jest --coverage --cache=false --runInBand --ci --coverageReporters=text-lcov | coveralls",
"test:watch": "jest --watch --cache=false",
"coveralls": "jscoverage lib && YOURPACKAGE_COVERAGE=1 nodeunit --reporter=text-lcov"
"coveralls": "jscoverage lib && YOURPACKAGE_COVERAGE=1 nodeunit --reporter=text-lcov",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
},
"repository": {
"type": "git",
Expand All @@ -34,6 +36,7 @@
"react-dom": "^15.x || ^16.x"
},
"devDependencies": {
"all-contributors-cli": "^5.3.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.5",
"babel-jest": "^23.4.0",
Expand Down
4 changes: 1 addition & 3 deletions src/scrollMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ export class ScrollMenu extends React.Component {

if (dragging || !afterScroll && !clickWhenDrag && diff > 5) return false;

if (onSelect) onSelect(id);
this.setState({ selected: id } );
this.setState({ selected: id }, () => { if (onSelect) onSelect(id); });
}

getVisibleItems = ({
Expand Down Expand Up @@ -583,7 +582,6 @@ export class ScrollMenu extends React.Component {

onUpdate = ({ selected = this.state.selected, translate = this.state.translate }) => {
const { onUpdate } = this.props;

if (onUpdate) {
onUpdate({ selected, translate });
}
Expand Down

0 comments on commit 24f0c79

Please sign in to comment.