Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinyChang committed Apr 7, 2019
2 parents e06c05a + a5f9846 commit dfe0870
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 111 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Changelog

- 0.14.0 Fix console warnings
- 0.14.0 Added new event hook: `onToggled`
- 0.13.1 Fix react warning of `maxCalculateTimes`
- 0.13.0 Shows all of the text when `line` is falsely, add `maxCalculateTimes` to prevent infinite loop
- 0.12.1 Update peerDependencies to support React 16
- 0.12.0 Added new prop: `textElement` for customize text render
- 0.11.2 Fix truncate incorrect in small size of width
- 0.11.0 Added two event hooks: `onTruncated` and `onCalculated`
- 0.10.4 Support inline style
- 0.10.3 Downgrade peerDependencies to `^15.4.1`
- 0.10.2 Fix truncated wrong when font property changed
- 0.10.1 Fix unknown prop `element`
- 0.10.0 Allow pass `element` to specify root element type
- 0.9.3 Fix SSR window not found (removed raf polyfill)
- 0.9.2 Fix styles prop is not working when the text is not truncated
- 0.9.1 Fix async this.forceUpdate() issue
- 0.9.0 Fix infinity loop bug, upgrade react to 15.5.4 and support yarn
- 0.8.3 IE 11 compatibility
- 0.8.2 Fix wrong truncating when a container has long words without spaces
- 0.8.1 Fix `textTruncateChild` bug
- 0.8.0 Drop `showTitle`, put `textTruncateChild` in same line if `tagName` is `A` or `SPAN`
- 0.7.2 Server render will display all text
- 0.7.1 Add new prop `containerClassName`
- 0.7.0 Fix infinite update bug, drop raf
- 0.6.2 Fix infinite loop bug
- 0.6.1 Fix lib issue for browser
- 0.6.0 Support React 15
- 0.5.2 Fix server render bug
- 0.5.1 Hide `textTruncateChild` when nothing truncated
- 0.5.0 Add request animation frame
- 0.4.0 New property `textTruncateChild` for show more or others
- 0.3.7 Support CommonJS and UMD module loader
- 0.3.5 Fix window resize issue
- 0.3.4 supports Babel6
- 0.2.0 supports React 0.14
- 0.1.5 supports React 0.13.3 and below
41 changes: 0 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,3 @@ var TextTruncate = require('react-text-truncate'); // CommonJS or UMD
2. Will TextTruncate support IE10 or below?

No! IE 10 and below are dead according to [Microsoft post](https://www.microsoft.com/en-us/WindowsForBusiness/End-of-IE-support).

3. Uncaught ReferenceError: requestAnimationFrame is not defined

Please polyfill `requestAnimationFrame` before you called `<TextTruncated />`

## Changelog

* 0.13.1 Fix react warning of `maxCalculateTimes`
* 0.13.0 Shows all of the text when `line` is falsely, add `maxCalculateTimes` to prevent infinite loop
* 0.12.1 Update peerDependencies to support React 16
* 0.12.0 Added new prop: `textElement` for customize text render
* 0.11.2 Fix truncate incorrect in small size of width
* 0.11.0 Added two event hooks: `onTruncated` and `onCalculated`
* 0.10.4 Support inline style
* 0.10.3 Downgrade peerDependencies to `^15.4.1`
* 0.10.2 Fix truncated wrong when font property changed
* 0.10.1 Fix unknown prop `element`
* 0.10.0 Allow pass `element` to specify root element type
* 0.9.3 Fix SSR window not found (removed raf polyfill)
* 0.9.2 Fix styles prop is not working when the text is not truncated
* 0.9.1 Fix async this.forceUpdate() issue
* 0.9.0 Fix infinity loop bug, upgrade react to 15.5.4 and support yarn
* 0.8.3 IE 11 compatibility
* 0.8.2 Fix wrong truncating when a container has long words without spaces
* 0.8.1 Fix `textTruncateChild` bug
* 0.8.0 Drop `showTitle`, put `textTruncateChild` in same line if `tagName` is `A` or `SPAN`
* 0.7.2 Server render will display all text
* 0.7.1 Add new prop `containerClassName`
* 0.7.0 Fix infinite update bug, drop raf
* 0.6.2 Fix infinite loop bug
* 0.6.1 Fix lib issue for browser
* 0.6.0 Support React 15
* 0.5.2 Fix server render bug
* 0.5.1 Hide `textTruncateChild` when nothing truncated
* 0.5.0 Add request animation frame
* 0.4.0 New property `textTruncateChild` for show more or others
* 0.3.7 Support CommonJS and UMD module loader
* 0.3.5 Fix window resize issue
* 0.3.4 supports Babel6
* 0.2.0 supports React 0.14
* 0.1.5 supports React 0.13.3 and below
14 changes: 12 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
window.cancelAnimationFrame(_this.rafId);
}
_this.rafId = window.requestAnimationFrame(_this.update.bind(_this));
}, _this.onToggled = function (truncated) {
typeof _this.props.onToggled === 'function' && setTimeout(function () {
return _this.props.onToggled(truncated);
}, 0);
}, _this.onTruncated = function () {
typeof _this.props.onTruncated === 'function' && setTimeout(function () {
return _this.props.onTruncated();
Expand Down Expand Up @@ -158,12 +162,13 @@
line = _props.line,
onCalculated = _props.onCalculated,
onTruncated = _props.onTruncated,
onToggled = _props.onToggled,
text = _props.text,
textElement = _props.textElement,
textTruncateChild = _props.textTruncateChild,
truncateText = _props.truncateText,
maxCalculateTimes = _props.maxCalculateTimes,
props = _objectWithoutProperties(_props, ['containerClassName', 'element', 'line', 'onCalculated', 'onTruncated', 'text', 'textElement', 'textTruncateChild', 'truncateText', 'maxCalculateTimes']);
props = _objectWithoutProperties(_props, ['containerClassName', 'element', 'line', 'onCalculated', 'onTruncated', 'onToggled', 'text', 'textElement', 'textTruncateChild', 'truncateText', 'maxCalculateTimes']);

var scopeWidth = this.scope.getBoundingClientRect().width;

Expand All @@ -174,6 +179,7 @@

// return if all of text can be displayed
if (scopeWidth >= this.measureWidth(text)) {
this.onToggled(false);
return (0, _react.createElement)(textElement, props, text);
}

Expand Down Expand Up @@ -261,10 +267,12 @@
}

if (startPos === maxTextLength) {
this.onToggled(false);
return (0, _react.createElement)(textElement, props, text);
}

this.onTruncated();
this.onToggled(true);
return _react2.default.createElement(
'div',
props,
Expand All @@ -286,11 +294,12 @@
line = _props2.line,
onCalculated = _props2.onCalculated,
onTruncated = _props2.onTruncated,
onToggled = _props2.onToggled,
textElement = _props2.textElement,
textTruncateChild = _props2.textTruncateChild,
truncateText = _props2.truncateText,
maxCalculateTimes = _props2.maxCalculateTimes,
props = _objectWithoutProperties(_props2, ['element', 'text', 'style', 'containerClassName', 'line', 'onCalculated', 'onTruncated', 'textElement', 'textTruncateChild', 'truncateText', 'maxCalculateTimes']);
props = _objectWithoutProperties(_props2, ['element', 'text', 'style', 'containerClassName', 'line', 'onCalculated', 'onTruncated', 'onToggled', 'textElement', 'textTruncateChild', 'truncateText', 'maxCalculateTimes']);

var fontWeight = style.fontWeight,
fontStyle = style.fontStyle,
Expand Down Expand Up @@ -321,6 +330,7 @@
line: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.bool]),
onCalculated: _propTypes2.default.func,
onTruncated: _propTypes2.default.func,
onToggled: _propTypes2.default.func,
text: _propTypes2.default.string,
textElement: _propTypes2.default.node,
textTruncateChild: _propTypes2.default.node,
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": "react-text-truncate",
"version": "0.13.1",
"version": "0.14.1",
"description": "Truncate text for React.js",
"main": "lib/index.js",
"scripts": {
Expand Down
Loading

0 comments on commit dfe0870

Please sign in to comment.