Socket
Socket
Sign inDemoInstall

l-count-up

Package Overview
Dependencies
16
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

dist/utils.js

85

dist/index.js

@@ -13,2 +13,8 @@ 'use strict';

var _rcTweenOne = require('rc-tween-one');
var _rcTweenOne2 = _interopRequireDefault(_rcTweenOne);
var _utils = require('./utils');
require('./index.scss');

@@ -41,40 +47,8 @@

});
var keeyDecimal = function keeyDecimal(num) {
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var res = parseFloat(num);
if (!res) return 0;
res = Math.round(num * Math.pow(10, n)) / Math.pow(10, n);
var x = res.toString();
var pos = x.indexOf('.');
if (pos < 0) {
pos = x.length;
x += '.';
}
while (x.length <= pos + n) {
x += '0';
}
return x;
};
var toMoney = function toMoney(num) {
var numArr = String(num).split('');
var pos = numArr.findIndex(function (v) {
return v === '.';
});
var after = pos >= 0 ? numArr.slice(pos, numArr.length) : [];
var arr = pos >= 0 ? numArr.slice(0, pos) : numArr;
var res = [];
var count = 0;
for (var i = arr.length - 1; i >= 0; i--) {
count++;
res.unshift(arr[i]);
if (count % 3 === 0 && i !== 0) res.unshift(',');
}
return res.concat(after).join('');
};
var fn = function fn(num) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'num';
if (type === 'percent') return +keeyDecimal(num);
if (type === 'money') return toMoney(keeyDecimal(num));
if (type === 'percent') return +(0, _utils.keeyDecimal)(num);
if (type === 'money') return (0, _utils.toMoney)((0, _utils.keeyDecimal)(num));
return num;

@@ -102,3 +76,3 @@ };

value: function componentDidMount() {
this.animation();
// this.animation();
}

@@ -108,3 +82,3 @@ }, {

value: function componentDidUpdate() {
this.animation();
// this.animation();
}

@@ -141,5 +115,8 @@ }, {

key: 'renderLi',
value: function renderLi() {
value: function renderLi(arr) {
var start = this.state.start;
var type = this.props.type;
var _props = this.props,
type = _props.type,
_props$animation = _props.animation,
animation = _props$animation === undefined ? {} : _props$animation;

@@ -150,4 +127,8 @@ if (type === 'percent') {

return _react2.default.createElement(
'li',
{ className: 'num-li', style: { top: 0 }, 'data-value': 0, key: '' + e + i },
_rcTweenOne2.default,
{ key: '' + e + i, component: 'li', animation: Object.assign({
duration: 1000
}, animation, {
top: arr[i]
}) },
spanNode

@@ -180,4 +161,8 @@ );

return _react2.default.createElement(
'li',
{ className: 'num-li', style: { top: 0 }, 'data-value': 0, key: '' + e + i },
_rcTweenOne2.default,
{ key: '' + e + i, component: 'li', animation: Object.assign({
duration: 1000
}, animation, {
top: arr[i]
}) },
spanNode

@@ -208,4 +193,8 @@ );

return _react2.default.createElement(
'li',
{ className: 'num-li', style: { top: 0 }, 'data-value': 0, key: '' + e + i },
_rcTweenOne2.default,
{ key: '' + e + i, component: 'li', animation: Object.assign({
duration: 1000
}, animation, {
top: arr[i]
}) },
spanNode

@@ -220,2 +209,8 @@ );

var start = this.state.start;
var arr = String(start).split('').map(function (e) {
return (/^[0-9]*$/.test(e) ? e * -30 : e
);
});
return _react2.default.createElement(

@@ -226,3 +221,3 @@ 'ul',

}, className: 'countUp' },
this.renderLi()
this.renderLi(arr)
);

@@ -229,0 +224,0 @@ }

{
"name": "l-count-up",
"version": "1.0.2",
"version": "1.0.3",
"description": "react ly-count-up",

@@ -27,2 +27,3 @@ "main": "dist/index.js",

"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",

@@ -43,4 +44,5 @@ "css-loader": "^2.1.0",

"dependencies": {
"rc-tween-one": "^2.3.4",
"scss": "^0.2.4"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc