From 9b6a1f27c41457e01c2b24b045bbf7c0f66357cb Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Wed, 26 Apr 2023 22:14:52 +0800 Subject: [PATCH] feat: placement (#228) * refactor: rename topCenter/bottomCenter with top/bottom * docs: update readme --- README.md | 12 ++---------- src/placements.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index be4bee6..c6c0ff3 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,7 @@ react dropdown component -[![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![Dependencies][david-image]][david-url] -[![DevDependencies][david-dev-image]][david-dev-url] -[![npm download][download-image]][download-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] +[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] [npm-image]: http://img.shields.io/npm/v/rc-dropdown.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-dropdown @@ -95,7 +88,7 @@ var Dropdown = require('rc-dropdown'); placement String bottomLeft - Position of menu item. There are: topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight + Position of menu item. There are: top, topCenter, topRight, bottomLeft, bottom, bottomRight onVisibleChange @@ -166,7 +159,6 @@ npm run coverage open coverage/ dir - ## License rc-dropdown is released under the MIT license. diff --git a/src/placements.ts b/src/placements.ts index 6159e27..f3fa8f5 100644 --- a/src/placements.ts +++ b/src/placements.ts @@ -1,9 +1,9 @@ const autoAdjustOverflow = { adjustX: 1, adjustY: 1, -} +}; -const targetOffset = [0, 0] +const targetOffset = [0, 0]; const placements = { topLeft: { @@ -12,7 +12,7 @@ const placements = { offset: [0, -4], targetOffset, }, - topCenter: { + top: { points: ['bc', 'tc'], overflow: autoAdjustOverflow, offset: [0, -4], @@ -30,7 +30,7 @@ const placements = { offset: [0, 4], targetOffset, }, - bottomCenter: { + bottom: { points: ['tc', 'bc'], overflow: autoAdjustOverflow, offset: [0, 4], @@ -42,6 +42,6 @@ const placements = { offset: [0, 4], targetOffset, }, -} +}; -export default placements +export default placements;