0.0.2 • Published 4 years ago

@ayase/vc-trigger v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

vc-trigger

NPM version David dm node version

rc-trigger for vue 3

Vue 3 Trigger Component

Install

vc-trigger

Usage

Include the default styling and then:

<template>
  <Trigger
    :action="['click']"
    :popup-align="{
      points: ['tl', 'bl'],
      offset: [0, 3]
    }"
  >
    <template v-slot:popup>
      <span>popup</span>
    </template>

    <a href="#">hover</a>
  </Trigger>
</template>

<script>
import Trigger from '@ayase/vc-trigger';

export default {
  components: { Trigger }
};
</script>

API

PropDescriptionTypeDefault
alignPointPopup will align with mouse position (support action of 'click', 'hover' and 'contextMenu')booleanfalse
popupClassadditional className added to popupstring-
forceRenderwhether render popup before first showbooleanfalse
destroyPopupOnHidewhether destroy popup when hidebooleanfalse
getPopupClassFromAlignadditional className added to popup according to align(align: object) => string-
actionwhich actions cause popup shown. enum of "hover", click, "focus", "contextMenu"string[]['hover']
mouseEnterDelaydelay time to show when mouse enter. unit: s.number0
mouseLeaveDelaydelay time to hide when mouse leave. unit: s.number0.1
popupStyleadditional style of popupObject-
prefixClsprefix class namestringvc-trigger-popup
popupTransitionNamevc-motionstring/Object-
maskTransitionNamevc-motionstring/Object-
maskwhether to support maskbooleanfalse
maskClosablewhether to support click mask to hidebooleantrue
popupVisiblewhether popup is visibleboolean-
zIndexpopup's zIndexnumber-
defaultPopupVisiblewhether popup is visible initiallyboolean-
popupAlignpopup 's align config, dom-alignobject-
getPopupContainerfunction returning html node which will act as popup container() => HTMLElement-
getDocumentfunction returning document node which will be attached click event to close trigger() => HTMLElement-
popupPlacementuse preset popup align config from builtinPlacements, can be merged by popupAlign propstring-
builtinPlacementsbuiltin placement align map. used by placement propobject-
stretchLet popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')string-

Slots

NameParamsDescription
popup() => VNode \| VNode[]popup content

Emits

NameParamsDescription
onPopupVisibleChange() => voidcall when popup visible is changed
onPopupAlign(popupDomNode, align) => voidcallback when popup node is aligned

Development

yarn install
yarn start

License

MIT