|
1 | 1 | /**
|
2 | 2 | * jquery-bootstrap-scrolling-tabs
|
3 |
| - * @version v2.4.0 |
| 3 | + * @version v2.6.0 |
4 | 4 | * @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs
|
5 | 5 | * @author Mike Jacobson <michaeljjacobson1@gmail.com>
|
6 | 6 | * @license MIT License, http://www.opensource.org/licenses/MIT
|
|
204 | 204 | * right-to-left languages. If true, the plugin will
|
205 | 205 | * check the page's <html> tag for attribute dir="rtl"
|
206 | 206 | * and will adjust its behavior accordingly.
|
| 207 | + * handleDelayedScrollbar: |
| 208 | + * set to true if you experience a situation where the |
| 209 | + * right scroll arrow wraps to the next line due to a |
| 210 | + * vertical scrollbar coming into existence on the page |
| 211 | + * after the plugin already calculated its width without |
| 212 | + * a scrollbar present. This would occur if, for example, |
| 213 | + * the bulk of the page's content loaded after a delay, |
| 214 | + * and only then did a vertical scrollbar become necessary. |
| 215 | + * It would also occur if a vertical scrollbar only appeared |
| 216 | + * on selection of a particular tab that had more content |
| 217 | + * than the default tab. |
207 | 218 | * bootstrapVersion:
|
208 | 219 | * set to 4 if you're using Boostrap 4. Default is 3.
|
209 | 220 | * Bootstrap 4 handles some things differently than 3
|
|
584 | 595 | .on(ev.CLICK, stc.tabClickHandler);
|
585 | 596 | }
|
586 | 597 |
|
| 598 | + if (settings.handleDelayedScrollbar) { |
| 599 | + ehd.listenForDelayedScrollbar(); |
| 600 | + } |
| 601 | + |
587 | 602 | stc.$win
|
588 | 603 | .off(resizeEventName)
|
589 | 604 | .smartresizeScrtabs(function (e) { evh.handleWindowResize.call(evh, e); }, resizeEventName);
|
590 | 605 |
|
591 | 606 | $('body').on(CONSTANTS.EVENTS.FORCE_REFRESH, stc.elementsHandler.refreshAllElementSizes.bind(stc.elementsHandler));
|
592 | 607 | };
|
593 | 608 |
|
| 609 | + p.listenForDelayedScrollbar = function () { |
| 610 | + var iframe = document.createElement('iframe'); |
| 611 | + iframe.id = "scrtabs-scrollbar-resize-listener"; |
| 612 | + iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;'; |
| 613 | + iframe.onload = function() { |
| 614 | + var timeout; |
| 615 | + |
| 616 | + function handleResize() { |
| 617 | + try { |
| 618 | + $(window).trigger('resize'); |
| 619 | + timeout = null; |
| 620 | + } catch(e) {} |
| 621 | + } |
| 622 | + |
| 623 | + iframe.contentWindow.addEventListener('resize', function() { |
| 624 | + if (timeout) { |
| 625 | + clearTimeout(timeout); |
| 626 | + } |
| 627 | + |
| 628 | + timeout = setTimeout(handleResize, 100); |
| 629 | + }); |
| 630 | + }; |
| 631 | + |
| 632 | + document.body.appendChild(iframe); |
| 633 | + }; |
| 634 | + |
594 | 635 | p.setFixedContainerWidth = function () {
|
595 | 636 | var ehd = this,
|
596 | 637 | stc = ehd.stc,
|
|
1955 | 1996 | tabsPostProcessors: null,
|
1956 | 1997 | enableSwiping: false,
|
1957 | 1998 | enableRtlSupport: false,
|
| 1999 | + handleDelayedScrollbar: false, |
1958 | 2000 | bootstrapVersion: 3
|
1959 | 2001 | };
|
1960 | 2002 |
|
|
0 commit comments