react-lines-ellipsis
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
v0.13.0 Add `props.onReflow()`. | ||
v0.12.0 Make `isClamped` more accurate. #27 | ||
v0.11.0 Pass rest props to `props.component`; Add `props.ellipsisHTML` for HTMLEllipsis. | ||
@@ -2,0 +6,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -94,2 +96,4 @@ | ||
basedOn: undefined, | ||
onReflow: function onReflow() {}, | ||
winWidth: undefined // for the HOC | ||
@@ -145,2 +149,10 @@ }; | ||
}, { | ||
key: 'setState', | ||
value: function setState(state, callback) { | ||
if (typeof state.clamped !== 'undefined') { | ||
this.clamped = state.clamped; | ||
} | ||
return _get(HTMLEllipsis.prototype.__proto__ || Object.getPrototypeOf(HTMLEllipsis.prototype), 'setState', this).call(this, state, callback); | ||
} | ||
}, { | ||
key: 'initCanvas', | ||
@@ -176,14 +188,9 @@ value: function initCanvas() { | ||
var clamped = this.putEllipsis(this.calcIndexes()); | ||
this.setClampedState({ clamped: clamped }); | ||
if (clamped) { | ||
this.setState({ html: this.canvas.innerHTML }); | ||
} | ||
var newState = { | ||
clamped: clamped, | ||
html: this.canvas.innerHTML | ||
}; | ||
this.setState(newState, props.onReflow.bind(this, newState)); | ||
} | ||
}, { | ||
key: 'setClampedState', | ||
value: function setClampedState(clamped) { | ||
this.clamped = clamped; | ||
this.setState({ clamped: clamped }); | ||
} | ||
}, { | ||
key: 'calcIndexes', | ||
@@ -190,0 +197,0 @@ value: function calcIndexes() { |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -40,2 +42,4 @@ | ||
basedOn: undefined, | ||
onReflow: function onReflow() {}, | ||
winWidth: undefined // for the HOC | ||
@@ -91,2 +95,10 @@ }; | ||
}, { | ||
key: 'setState', | ||
value: function setState(state, callback) { | ||
if (typeof state.clamped !== 'undefined') { | ||
this.clamped = state.clamped; | ||
} | ||
return _get(LinesEllipsis.prototype.__proto__ || Object.getPrototypeOf(LinesEllipsis.prototype), 'setState', this).call(this, state, callback); | ||
} | ||
}, { | ||
key: 'initCanvas', | ||
@@ -134,14 +146,9 @@ value: function initCanvas() { | ||
var clamped = ellipsisIndex > -1; | ||
this.setClampedState(clamped); | ||
this.setState({ | ||
var newState = { | ||
clamped: clamped, | ||
text: clamped ? this.units.slice(0, ellipsisIndex).join('') : props.text | ||
}); | ||
}; | ||
this.setState(newState, props.onReflow.bind(this, newState)); | ||
} | ||
}, { | ||
key: 'setClampedState', | ||
value: function setClampedState(clamped) { | ||
this.clamped = clamped; | ||
this.setState({ clamped: clamped }); | ||
} | ||
}, { | ||
key: 'calcIndexes', | ||
@@ -148,0 +155,0 @@ value: function calcIndexes() { |
{ | ||
"name": "react-lines-ellipsis", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Simple multiline ellipsis component for React.JS", | ||
@@ -11,2 +11,3 @@ "main": "lib/index.js", | ||
"test": "standard", | ||
"lint:fix": "standard --fix", | ||
"prebuild": "mkdir -p lib", | ||
@@ -48,3 +49,3 @@ "build": "for js in src/*.js; do babel $js > \"lib/$(basename $js)\"; done", | ||
"standard": "11.0.1", | ||
"uglify-js": "3.4.0", | ||
"uglify-js": "3.4.3", | ||
"watchify": "3.11.0" | ||
@@ -51,0 +52,0 @@ }, |
32859
5.08%611
2%