Skip to content

Commit

Permalink
1. 配置项 sort 控制是否自动排序
Browse files Browse the repository at this point in the history
2. 通过 dangerouslySetInnerHTML 渲染 name 数据
  • Loading branch information
yizhiyuyou committed Dec 27, 2019
1 parent 8653d45 commit 74f9c6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.0.10-alpha (2019-12-27)

### Perfect

- **ScrollRankingBoard:** 配置项 sort 控制是否自动排序.
- **ScrollRankingBoard:** 通过 dangerouslySetInnerHTML 渲染 name 数据.

# 1.0.8-alpha (2019-12-17)

### Feature
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jiaminghi/data-view-react",
"version": "1.0.9",
"version": "1.0.10",
"description": "React Large screen data display component library",
"author": "Duan Yu <[email protected]>",
"license": "MIT",
Expand All @@ -20,7 +20,7 @@
"prepare": "yarn run build"
},
"dependencies": {
"@jiaminghi/charts": "^0.2.8"
"@jiaminghi/charts": "^0.2.10"
},
"peerDependencies": {
"react": "^16.8.0",
Expand Down
20 changes: 13 additions & 7 deletions src/components/scrollRankingBoard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ const defaultConfig = {
* @default unit = ''
* @example unit = 'ton'
*/
unit: ''
unit: '',
/**
* @description Auto sort by value
* @type {Boolean}
* @default sort = true
*/
sort: true
}

function calcRows({ data, rowNum }) {
data.sort(({ value: a }, { value: b }) => {
function calcRows({ data, rowNum, sort }) {
sort && data.sort(({ value: a }, { value: b }) => {
if (a > b) return -1
if (a < b) return 1
if (a === b) return 0
Expand Down Expand Up @@ -137,7 +143,7 @@ const ScrollRankingBoard = ({ config, className, style }) => {
}
}

function * animation(start = false) {
function* animation(start = false) {
let {
avgHeight,
animationIndex,
Expand Down Expand Up @@ -176,9 +182,9 @@ const ScrollRankingBoard = ({ config, className, style }) => {

let start = true

function * loop() {
function* loop() {
while (true) {
yield * animation(start)
yield* animation(start)

start = false

Expand Down Expand Up @@ -225,7 +231,7 @@ const ScrollRankingBoard = ({ config, className, style }) => {
>
<div className='ranking-info'>
<div className='rank'>No.{item.ranking}</div>
<div className='info-name'>{item.name}</div>
<div className='info-name' dangerouslySetInnerHTML={{ __html: item.name }} />
<div className='ranking-value'>
{item.value + mergedConfig.unit}
</div>
Expand Down

0 comments on commit 74f9c6b

Please sign in to comment.