Skip to content

Commit

Permalink
Merge pull request #9 from TaylorBriggs/fix/invisible-style
Browse files Browse the repository at this point in the history
Fix invisible text style
  • Loading branch information
TaylorBriggs committed May 4, 2017
2 parents 91d1fb0 + d9c60d2 commit de34410
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"extends": "airbnb",
"rules": {
"comma-dangle": [2, "never"],
"import/no-extraneous-dependencies": 0,
"no-mixed-operators": 0,
"comma-dangle": ["error", "never"],
"import/no-extraneous-dependencies": "off",
"no-mixed-operators": "off",
"react/jsx-filename-extension": [
1,
"warn",
{
"extensions": [
".js",
".jsx"
]
}
],
"react/require-default-props": 0
"react/require-default-props": "off"
}
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
- Unhandled JS Exception with `fixed` and `style` props

## [0.5.0] — 2017-04-11
### Added
Expand Down
34 changes: 18 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const delayShape = PropTypes.shape({

const propTypes = {
children: PropTypes.string.isRequired,
fixed: PropTypes.bool,
typing: PropTypes.oneOf([-1, 0, 1]),
maxDelay: PropTypes.number,
minDelay: PropTypes.number,
Expand All @@ -28,7 +29,7 @@ const defaultProps = {
maxDelay: MAX_DELAY,
minDelay: MAX_DELAY / 5,
typing: 0,
fixed: false,
fixed: false
};

function isEqual(current, next) {
Expand Down Expand Up @@ -130,36 +131,37 @@ class TypeWriter extends Component {
const { fixed, children, ...props } = this.props;
const { visibleChars } = this.state;

const visibleString = children.slice(0, visibleChars)
const visibleString = children.slice(0, visibleChars);

let components = [(
const components = [(
<Text
{ ...props }
key="visible-string">
{...props}
key="visible-string"
>
{visibleString}
</Text>
)];

if (fixed) {
const invisibleString = children.slice(visibleChars)
const invisibleStyle = { ...props.style, opacity: 0 }
const invisibleString = children.slice(visibleChars);
const invisibleStyle = { opacity: 0 };

components.push(
<Text
{ ...props }
style={invisibleStyle}
key="invisible-string">
{...props}
style={[...props.style, invisibleStyle]}
key="invisible-string"
>
{invisibleString}
</Text>
);
}
return (
<Text>
{components}
</Text>
);

return <Text>{components}</Text>;
}
}

TypeWriter.propTypes = propTypes;
TypeWriter.defaultProps = defaultProps;

export default TypeWriter
export default TypeWriter;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"react-native": "^0.42.0"
},
"devDependencies": {
"eslint": "3.17.1",
"eslint": "3.19.0",
"eslint-config-airbnb": "14.1.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.10.0",
"eslint-plugin-react": "6.10.3",
"pre-commit": "1.2.2",
"react": "15.4.2",
"react-native": "0.42.0"
Expand Down

0 comments on commit de34410

Please sign in to comment.