1.0.2 • Published 4 years ago

rusion-popper v1.0.2

Weekly downloads
3
License
ISC
Repository
-
Last release
4 years ago

rusion-popper

A popper manager library

Online Demo

Install

npm i rusion-popper

Get start

prepare a target element

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

prepare a popper element

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

create popper instance

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

Parameters

The constructor options of RusionPopper

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.rusion-popper-arrow under popper element.
arrowSizenumberdefault is 20, the size of the popper arrow

Methods

RusionPopper.prototype

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

RusionTooltip

prepare target element like this:

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

create tooltip instance

new RusionPopper.RusionTooltip({
    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 RusionTooltip

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.rusion-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