Sha256: 9ab60b1d8ee148998f4eaec66d83a0c8eed0a8c0b3cc1d8531f9d55545ca6560
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
import { createPopper } from '@popperjs/core' class Popover { constructor( triggerElement = '#triggerElement', tooltip = '#tooltip', placement = 'left', offset = '' ) { this.triggerElement = triggerElement this.tooltip = tooltip this.placement = placement this.offset = offset this.setupPopper() } //getters get popoverTriggerElement() { return document.querySelector(this.triggerElement) } get popoverTooltip() { return document.querySelector(this.tooltip) } get popoverPlacement() { return this.placement } get popoverOffset() { return this.offset } attachEvents() { this.popoverTriggerElement.addEventListener('click', () => { this.popoverTooltip.classList.toggle('show') }) } setupPopper() { createPopper(this.popoverTriggerElement, this.popoverTooltip, { placement: this.popoverPlacement, modifiers: [ { name: 'offset', options: { offset: this.offset, }, }, ], }) this.attachEvents() } } export default Popover
Version data entries
4 entries across 4 versions & 1 rubygems