Skip to content

JacobZyy/trigger

This branch is 39 commits behind react-component/trigger:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 26, 2024
a1c0a66 · Jan 26, 2024
Apr 10, 2023
May 8, 2023
Oct 16, 2023
Jan 25, 2024
Jan 25, 2024
Feb 15, 2023
Oct 29, 2015
Feb 23, 2021
Oct 26, 2022
Jan 7, 2023
May 16, 2023
May 8, 2020
May 6, 2016
May 10, 2023
Oct 29, 2015
Oct 26, 2022
Oct 10, 2019
Jan 26, 2024
May 8, 2023

Repository files navigation

@rc-component/trigger

React Trigger Component

NPM version npm download build status Test coverage bundle size dumi

Install

@rc-component/trigger

Usage

Include the default styling and then:

import React from 'react';
import ReactDOM from 'react-dom';
import Trigger from '@rc-component/trigger';

ReactDOM.render((
  <Trigger
    action={['click']}
    popup={<span>popup</span>}
    popupAlign={{
      points: ['tl', 'bl'],
      offset: [0, 3]
    }}
  >
    <a href='#'>hover</a>
  </Trigger>
), container);

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

Example

http://localhost:9001

Development

npm install
npm start

API

props

name type default description
alignPoint bool false Popup will align with mouse position (support action of 'click', 'hover' and 'contextMenu')
popupClassName string additional className added to popup
forceRender boolean false whether render popup before first show
destroyPopupOnHide boolean false whether destroy popup when hide
getPopupClassNameFromAlign getPopupClassNameFromAlign(align: Object):String additional className added to popup according to align
action string[] ['hover'] which actions cause popup shown. enum of 'hover','click','focus','contextMenu'
mouseEnterDelay number 0 delay time to show when mouse enter. unit: s.
mouseLeaveDelay number 0.1 delay time to hide when mouse leave. unit: s.
popupStyle Object additional style of popup
prefixCls String rc-trigger-popup prefix class name
popupTransitionName String|Object https://github.com/react-component/animate
maskTransitionName String|Object https://github.com/react-component/animate
onPopupVisibleChange Function call when popup visible is changed
mask boolean false whether to support mask
maskClosable boolean true whether to support click mask to hide
popupVisible boolean whether popup is visible
zIndex number popup's zIndex
defaultPopupVisible boolean whether popup is visible initially
popupAlign Object: alignConfig of [dom-align](https://github.com/yiminghe/dom-align) popup 's align config
onPopupAlign function(popupDomNode, align) callback when popup node is aligned
popup React.Element | function() => React.Element popup content
getPopupContainer getPopupContainer(): HTMLElement function returning html node which will act as popup container
getDocument getDocument(): HTMLElement function returning document node which will be attached click event to close trigger
popupPlacement string use preset popup align config from builtinPlacements, can be merged by popupAlign prop
builtinPlacements object builtin placement align map. used by placement prop
stretch string Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')

Test Case

npm test
npm run coverage

open coverage/ dir

License

rc-trigger is released under the MIT license.

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 66.1%
  • JavaScript 32.0%
  • Less 1.9%