Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-line-clamp

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-line-clamp - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

61

Clamp.js

@@ -64,40 +64,35 @@ 'use strict';

var heightOfWrap = this._getWrapRect_().height;
var heightOfContext = this._getContextRect_().height;
var text = this.rawContextText;
var ellipsis = this.props.ellipsis || '';
if (heightOfContext > heightOfWrap) {
var text = this.rawContextText;
var ellipsis = this.props.ellipsis || '';
var low = 0,
high = text.length,
mid = void 0;
var count = 0;
var low = 0,
high = text.length,
mid = void 0;
var count = 0;
var clamp = function clamp() {
if (count > 100) return;
count++;
var clamp = function clamp() {
if (count > 100) return;
count++;
mid = (low + high) / 2 | 0;
var _text = text.slice(0, mid);
_this2.refs.context.innerHTML = _text + ellipsis;
mid = (low + high) / 2 | 0;
var _text = text.slice(0, mid);
_this2.refs.context.innerHTML = _text + ellipsis;
var contextHeight = _this2._getContextRect_().height;
var wrapHeight = _this2._getWrapRect_().height;
var contextHeight = _this2._getContextRect_().height;
var wrapHeight = _this2._getWrapRect_().height;
if (contextHeight > wrapHeight) {
high = mid - 1;
} else {
low = mid + 1;
}
if (contextHeight > wrapHeight) {
high = mid - 1;
} else {
low = mid + 1;
}
if (low <= high) {
_this2.requestAnimationFrameHandler = _requestAnimationFrame_(clamp);
} else {
_this2.refs.context.innerHTML = _text.slice(0, mid - 1) + ellipsis;
}
};
if (low <= high) {
_this2.requestAnimationFrameHandler = _requestAnimationFrame_(clamp);
} else {
_this2.refs.context.innerHTML = _text.slice(0, mid - 1) + ellipsis;
}
};
clamp();
}
clamp();
}

@@ -110,2 +105,3 @@ }, {

this.rawContextText = this.refs.context.innerText;
console.log(this.rawContextText);
this.adjustContext();

@@ -139,3 +135,4 @@

'div',
{ ref: 'context', className: this.props.innerClassName, style: this.props.innerStyle, dangerouslySetInnerHTML: this.props.dangerouslySetInnerHTML },
{ ref: 'context', className: this.props.innerClassName, style: this.props.innerStyle,
dangerouslySetInnerHTML: this.props.dangerouslySetInnerHTML },
this.props.children

@@ -142,0 +139,0 @@ )

{
"name": "react-line-clamp",
"version": "1.2.3",
"version": "1.2.4",
"description": "A react component which can help you implememt line-clamp automatically",

@@ -5,0 +5,0 @@ "main": "Clamp.js",

@@ -29,39 +29,33 @@ import React from 'react';

adjustContext() {
const text = this.rawContextText;
const ellipsis = this.props.ellipsis || '';
const heightOfWrap = this._getWrapRect_().height;
const heightOfContext = this._getContextRect_().height;
let low = 0, high = text.length, mid;
let count = 0;
if (heightOfContext > heightOfWrap) {
const text = this.rawContextText;
const ellipsis = this.props.ellipsis || '';
const clamp = () => {
if (count > 100) return;
count++;
let low = 0, high = text.length, mid;
let count = 0;
mid = (low + high) / 2 | 0;
const _text = text.slice(0, mid);
this.refs.context.innerHTML = _text + ellipsis;
const clamp = () => {
if (count > 100) return;
count++;
const contextHeight = this._getContextRect_().height;
const wrapHeight = this._getWrapRect_().height;
mid = (low + high) / 2 | 0;
const _text = text.slice(0, mid);
this.refs.context.innerHTML = _text + ellipsis;
if (contextHeight > wrapHeight) {
high = mid - 1;
} else {
low = mid + 1;
}
const contextHeight = this._getContextRect_().height;
const wrapHeight = this._getWrapRect_().height;
if (low <= high) {
this.requestAnimationFrameHandler = _requestAnimationFrame_(clamp);
} else {
this.refs.context.innerHTML = _text.slice(0, mid - 1) + ellipsis;
}
};
if (contextHeight > wrapHeight) {
high = mid - 1;
} else {
low = mid + 1;
}
if (low <= high) {
this.requestAnimationFrameHandler = _requestAnimationFrame_(clamp);
} else {
this.refs.context.innerHTML = _text.slice(0, mid - 1) + ellipsis;
}
};
clamp();
}
clamp();
}

@@ -71,2 +65,3 @@

this.rawContextText = this.refs.context.innerText;
console.log(this.rawContextText)
this.adjustContext();

@@ -95,3 +90,4 @@

return <div className={this.props.className} ref="wrap" style={this.props.style}>
<div ref="context" className={this.props.innerClassName} style={this.props.innerStyle} dangerouslySetInnerHTML={this.props.dangerouslySetInnerHTML}>{this.props.children}</div>
<div ref="context" className={this.props.innerClassName} style={this.props.innerStyle}
dangerouslySetInnerHTML={this.props.dangerouslySetInnerHTML}>{this.props.children}</div>
</div>

@@ -98,0 +94,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc