0.0.7 • Published 4 years ago

yirous-popper v0.0.7

Weekly downloads
20
License
-
Repository
-
Last release
4 years ago

yirous-popper

A popper manager library

Online Demo

Install

npm i yirous-popper -S

Get start

prepare a target element

<button id="target"> I am target</button>

prepare a popper element

<div id="popper">
    <div class="yirous-popper-content">
        popper content
    </div>
</div>

create popper instance

new YirousPopper({
    popperEl: document.querySelector('#popper'),
    targetEl: document.querySelector('#target')
})

Parameters

The constructor options of YirousPopper

nametypedesc
popperElHTMLElementpopper element(not selector string)
targetElHTMLElementtarget element(not selector string)
offsetnumberduration between target and popper(not include arrow size)
boundaryHTMLElement,selector string,windowthe boundary element to contain the popper element
placementstringdefault:bottom, can be: top,left,bottom,right, top-start,top-center,top-end, bottom-start,bottom-center,bottom-end, left-start,left-center,left-end, right-start,right-center,right-end,
backgroundColorstringthe backgroundColor of the popper content and popper arrow
boxShadowstringthe boxShadow of the popper content and popper arrow
arrowbooleandefault is false, if true, you need to provide div.yirous-popper-arrow under popper element.
arrowSizenumberdefault is 20, the size of the popper arrow

Methods

YirousPopper.prototype

namedesc
refreshrefresh the position of the popper
destroyrelease variable and unbind event
setPlacement(placement:string)change placement

YirousTooltip

prepare target element like this:

<button id="target">target</button>

create tooltip instance

new Yirouspopper.YirousTooltip({
    targetEl: document.querySelector('#target'),
    content: 'this is tooltip content, content parameter also can accept a HTMLElement to customize tooltip content'
})

Parameters

The constructor options of YirousTooltip

nametypedesc
targetElHTMLElementtarget element(not selector string)
offsetnumberduration between target and popper(not include arrow size)
boundaryHTMLElement,selector string,windowthe boundary element to contain the popper element
placementstringdefault:bottom, can be: top,left,bottom,right, top-start,top-center,top-end, bottom-start,bottom-center,bottom-end, left-start,left-center,left-end, right-start,right-center,right-end,
backgroundColorstringthe backgroundColor of the popper content and popper arrow
boxShadowstringthe boxShadow of the popper content and popper arrow
arrowbooleandefault is false, if true, you need to provide div.yirous-popper-arrow under popper element.
arrowSizenumberdefault is 20, the size of the popper arrow
---------
theme'light','dark'(default)the style of tooltip
animate'scale','drop','fade'(default)the animation of tooltip when show and hide
contentstring,HTMLElementthis content of tooltip
trigger'always'(default),'click','focus','hover','manual'the way to show tooltip
removeOnHideboolean(true)when tooltip is hide, tooltip will automatically remove tooltip element from body