Skip to content

Commit

Permalink
Feature/remove click to pause (#2)
Browse files Browse the repository at this point in the history
* BREAKING CHANGE: Remove Click To Pause feature

The animation control should not be responsibility of the player

* chore: bump version number

* chore(release): 1.3.4
  • Loading branch information
felippenardi authored Jul 29, 2018
1 parent 7743d39 commit ec550bf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.3.4"></a>
## [1.3.4](https://github.com/felippenardi/lottie-react-web/compare/v1.2.3...v1.3.4) (2018-07-29)



<a name="1.2.4"></a>
## [1.2.4](https://github.com/felippenardi/lottie-react-web/compare/v1.2.3...v1.2.4) (2018-07-29)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lottie-react-web",
"version": "1.2.4",
"version": "1.3.4",
"description": "Lottie wrapper for React on the web.",
"repository": {
"type": "git",
Expand Down
16 changes: 0 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,12 @@ export default class Lottie extends React.Component {
});
}

handleClickToPause = () => {
// The pause() method is for handling pausing by passing a prop isPaused
// This method is for handling the ability to pause by clicking on the animation
if (this.anim.isPaused) {
this.anim.play();
} else {
this.anim.pause();
}
}

render() {
const {
width,
height,
ariaRole,
ariaLabel,
isClickToPauseDisabled,
title,
} = this.props;

Expand All @@ -150,8 +139,6 @@ export default class Lottie extends React.Component {
...this.props.style,
};

const onClickHandler = isClickToPauseDisabled ? () => null : this.handleClickToPause;

return (
// Bug with eslint rules https://github.com/airbnb/javascript/issues/1374
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
Expand All @@ -160,7 +147,6 @@ export default class Lottie extends React.Component {
this.el = c;
}}
style={lottieStyles}
onClick={onClickHandler}
title={title}
role={ariaRole}
aria-label={ariaLabel}
Expand All @@ -182,7 +168,6 @@ Lottie.propTypes = {
direction: PropTypes.number,
ariaRole: PropTypes.string,
ariaLabel: PropTypes.string,
isClickToPauseDisabled: PropTypes.bool,
title: PropTypes.string,
style: PropTypes.string,
};
Expand All @@ -194,6 +179,5 @@ Lottie.defaultProps = {
speed: 1,
ariaRole: 'button',
ariaLabel: 'animation',
isClickToPauseDisabled: false,
title: '',
};
19 changes: 0 additions & 19 deletions src/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@ const defaultOptions = {

describe('react-lottie', () => {
describe('props', () => {
describe('isClickToPauseDisabled', () => {
it('should prevent handleClickToPause from being called when true', () => {
const component = mount(<ReactLottie options={defaultOptions} />);
const spy = sinon.stub();

component.instance().handleClickToPause = spy;
component.instance().forceUpdate();
component.find('div').at(0).simulate('click');

expect(spy.callCount).to.equal(1);

spy.reset();
component.setProps({ isClickToPauseDisabled: true });
component.find('div').at(0).simulate('click');

expect(spy.callCount).to.equal(0);
});
});

describe('ariaRole, ariaLabel, and title', () => {
it('should set the aria role correctly', () => {
const component = shallow(
Expand Down

0 comments on commit ec550bf

Please sign in to comment.