Merge pull request #165 from lbryio/fix-clamp-js-firefox

Fix line clamping on Firefox
This commit is contained in:
Jeremy Kauffman 2017-02-10 12:13:07 -05:00 committed by GitHub
commit 227e23653d
3 changed files with 12 additions and 4 deletions

View file

@ -1,6 +1,6 @@
import React from 'react';
import lbry from '../lbry.js';
import $clamp from 'clamp-js';
import $clamp from 'clamp-js-main';
//component/icon.js
export let Icon = React.createClass({
@ -31,13 +31,17 @@ export let TruncatedText = React.createClass({
}
},
componentDidMount: function() {
// Manually round up the line height, because clamp.js doesn't like fractional-pixel line heights.
// Need to work directly on the style object because setting the style prop doesn't update internal styles right away.
this.refs.span.style.lineHeight = Math.ceil(parseFloat(getComputedStyle(this.refs.span).lineHeight)) + 'px';
$clamp(this.refs.span, {
clamp: this.props.lines || this.props.height || 'auto',
});
},
render: function() {
var text = this.props.children;
return <span ref="span">{text}</span>;
return <span ref="span" className="truncated-text">{this.props.children}</span>;
}
});

View file

@ -22,7 +22,7 @@
"babel-cli": "^6.11.4",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"clamp-js": "^0.7.0",
"clamp-js-main": "^0.11.1",
"mediaelement": "^2.23.4",
"node-sass": "^3.8.0",
"react": "^15.4.0",

View file

@ -121,6 +121,10 @@ input[type="text"], input[type="search"]
height: $spacing-vertical * 1.5;
}
.truncated-text {
display: inline-block;
}
.busy-indicator
{
background: url('../img/busy.gif') no-repeat center center;