@lovata/popup-helper
v1.0.1
Published
Package adds helper methods for work with modal window
Downloads
3
Readme
Popup helper package
installation
npm install @lovata/popup-helper
Initialization
import PopupHelper from '@lovata/popup-helper';
@import '@lovata/popup-helper/css/popup-helper';
This css allows for work with only 2 viewport types: mobile (less then 769px) and desktop. If you want change it so you should use changeNoScrollSelector()
method
Methods
changeNoScrollSelector()
Change class for scroll disabling
saveScrollPosition()
Return scroll position
setScrollPosition()
Save scroll position before modal opening
setBodyScrollState(needScroll)
Complex method. Depending @param needScroll toggle class on body,
save or set scroll position and padding to avoid shifting content
| Param | Type | | --- | --- | | needScroll | boolean |
focusTrapManager(needTrap, modal)
| Param | Type | Description | | --- | --- | --- | | needTrap | boolena | if true - enable focus trap | | modal | node | node of modal window |
getScrollBarWidth()
Returns: scrollBar width (type: int)
setBodyPadding()
Set css custom-property equal scrollbar width
checkOverlay() boolean
Return false if overlay was create
overlayController(needOverlay)
Ff @param needOverlay is true create Node for overlay, else remove it
| Param | Type | | --- | --- | | needOverlay | boolean |
overlayHandler(isInit, closeBtnNode, modalNode)
Complex method. Create of remove overlay and if **@param isInit** is true, so set flags and **click** and **esc button press** handlers
| Param | Type | | --- | --- | | isInit | boolean | | closeBtnNode | node | | modalNode | node |
createOverlay()
Create overlay node
removeOverlay()
Remove overlay node
getOverlay()
Returns: overlay node
overlayClickHandler(triggerTarget)
Add 'click' handler to overlay
| Param | Type | Description | | --- | --- | --- | | triggerTarget | node | Node for close modal window |
escPressHandler(triggerTarget, modalNode)
Add esc button press handler
| Param | Type | Description | | --- | --- | --- | | triggerTarget | node | Node for close modal window | | modalNode | node | Node of modal window |
License
© 2019, LOVATA Group, LLC under GNU GPL v3.
Developed by Uladzimir Ambrazhei.