DanielST
DanielST

Reputation: 14133

fullcalendar with qtip2 - How do I make the qtip scroll correctly?

This works - JSFiddle

$("#FullCalendar").fullCalendar({
    timezone: false,
    defaultView: "agendaWeek",
    eventLimit: true,
    events: [{
        title: 'event1',
        start: moment().startOf('day').add(8,'hours')
    }],
    eventAfterRender: function(event, element) {
        var $viewport = $(".fc-time-grid-container.fc-scroller");
        var qapi = $(element).qtip({
            content: "woo",
            hide: {
                event: false
            }
        }).qtip('api');
        $viewport.on("scroll", function () {
            qapi.reposition();
        });
        qapi.show();
        event.qapi = qapi;
    },
    eventDestroy: function( event, element, view ) {
        event.qapi.destroy();
    },
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    }
});

The problem is that it isn't hidden when you scroll down far enough: scrolling problem

I found several places that say the solution is to set position.container as the scrolling div which should take care of this problem (and maybe the need for a scroll event listener too). But position.container only seems to break things for me.

None of these work: (JSFiddle)

position: {
    //container: element.parent()
    //container: element
    container: $viewport
}

I've also tried using position.viewport and position.target.

Upvotes: 0

Views: 1077

Answers (1)

Ahmad Ibrahim
Ahmad Ibrahim

Reputation: 1925

You can check if the element is visible after scrolling, and show/hide the qtip accordingly.

$viewport.on("scroll", function () {
            if(isScrolledIntoView(element[0])) {
                qapi.show();
                qapi.reposition();
            }
            else {
                qapi.hide();
            }
        });

Check this Fiddle

Edit: A nice way to check element visibility can be found here

Upvotes: 1

Related Questions