atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
12.03k stars 520 forks source link

Enable/disable on delegate addon. #878

Closed bilalmalkoc closed 3 years ago

bilalmalkoc commented 3 years ago
import { delegate } from 'tippy.js';

const breakPoint = window.matchMedia('(max-width:767px)');

const tippyInstance = delegate('.tippy-parent', {
    animation: 'shift-away',
    target: '[data-tippy-content]',
});

const breakpointChecker = function () {
    if (breakPoint.matches === true) {
        tippyInstance.disable();
    } else if (breakPoint.matches === false) {
        tippyInstance.enable();
    }
};

breakPoint.addListener(breakpointChecker);

I got this error:

tippyInstance.enable is not a function

atomiks commented 3 years ago

Log out tippyInstance and you'll see.

bilalmalkoc commented 3 years ago

Thank you but i dont understand what did you mean.

atomiks commented 3 years ago

It's an array not an instance. console.log(tippyInstance)

bilalmalkoc commented 3 years ago

Why it is not a instance? Can you suggest any way to use disable/enable method?