diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e7b86..7deded9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# 1.2.5-alpha (2020-11-15) + +### New + +- **decoration12:** New decoration(Radar scan). + +### Optmization + +- **ScrollBoard:** Reduce redundant node rendering. +- **ScrollRankingBoard:** Reduce redundant node rendering. +- **ScrollRankingBoard:** Add value formatter. +- **BorderBox:** Canonical class name. +- **useAutoResize(hooks):** Add exception prompt. +- **Decoration** add `dur` configuration. +- **ActiveRingChart** add `digitalFlopUnit` configuration. + # 1.2.4-alpha (2020-7-25) ### Bug 修复 @@ -70,12 +86,14 @@ ### Feature - **BorderBox & Decoration:** **Configurable** color. + ```html ``` -- **ScrollBoard:** 配置 header index. + +- **ScrollBoard:** 配置 header index. ### New diff --git a/package.json b/package.json index 0e4bfeb..3a52989 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jiaminghi/data-view-react", - "version": "1.2.4", + "version": "1.2.5", "description": "React Large screen data display component library", "author": "Duan Yu <949267840@qq.com>", "license": "MIT", @@ -65,4 +65,4 @@ "es", "umd" ] -} \ No newline at end of file +} diff --git a/src/components/scrollBoard/index.js b/src/components/scrollBoard/index.js index 77e8dbe..fbea7c4 100644 --- a/src/components/scrollBoard/index.js +++ b/src/components/scrollBoard/index.js @@ -270,6 +270,7 @@ const ScrollBoard = forwardRef(({ onClick, config = {}, className, style, onMous let rows = rowsData.slice(animationIndex) rows.push(...rowsData.slice(0, animationIndex)) + rows = rows.slice(0, carousel === 'page' ? rowNum * 2 : rowNum + 1) const heights = new Array(rowLength).fill(avgHeight) setState(state => ({ ...state, rows, heights })) diff --git a/src/components/scrollRankingBoard/index.js b/src/components/scrollRankingBoard/index.js index 859bf69..7d37698 100644 --- a/src/components/scrollRankingBoard/index.js +++ b/src/components/scrollRankingBoard/index.js @@ -51,7 +51,13 @@ const defaultConfig = { * @type {Boolean} * @default sort = true */ - sort: true + sort: true, + /** + * @description Value formatter + * @type {Function} + * @default valueFormatter = null + */ + valueFormatter: null } function calcRows({ data, rowNum, sort }) { @@ -170,6 +176,7 @@ const ScrollRankingBoard = forwardRef(({ config = {}, className, style }, ref) = let rows = rowsData.slice(animationIndex) rows.push(...rowsData.slice(0, animationIndex)) + rows = rows.slice(0, rowNum + 1) const heights = new Array(rowLength).fill(avgHeight) setState(state => ({ ...state, rows, heights })) @@ -244,7 +251,7 @@ const ScrollRankingBoard = forwardRef(({ config = {}, className, style }, ref) =
No.{item.ranking}
- {item.value + mergedConfig.unit} + {mergedConfig.valueFormatter ? mergedConfig.valueFormatter(item) : item.value + mergedConfig.unit}
diff --git a/src/use/autoResize.js b/src/use/autoResize.js index f196ad5..b924659 100644 --- a/src/use/autoResize.js +++ b/src/use/autoResize.js @@ -7,9 +7,15 @@ export default function useAutoResize(ref) { const domRef = useRef(null) const setWH = useCallback(() => { - const { clientWidth, clientHeight } = domRef.current + const { clientWidth, clientHeight } = domRef.current || { clientWidth: 0, clientHeight: 0 } setState({ width: clientWidth, height: clientHeight }) + + if (!domRef.current) { + console.warn('DataV: Failed to get dom node, component rendering may be abnormal!') + } else if (!clientWidth || !clientHeight) { + console.warn('DataV: Component width or height is 0px, rendering abnormality may occur!') + } }, []) useImperativeHandle(ref, () => ({ setWH }), []) @@ -24,10 +30,14 @@ export default function useAutoResize(ref) { window.addEventListener('resize', debounceSetWHFun) return () => { + window.removeEventListener('resize', debounceSetWHFun) + + if (!domObserver) { + return + } + domObserver.disconnect() domObserver.takeRecords() - - window.removeEventListener('resize', debounceSetWHFun) } }, [])