(function(root, factory) {
if (typeof define === 'function' && define.amd) {
} else if (typeof exports === 'object') {
module.exports = factory();
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var TetherBase = undefined;
if (typeof TetherBase === 'undefined') {
TetherBase = { modules: [] };
// Same as native getBoundingClientRect, except it takes into account parent <frame> offsets
// if the element lies within a nested document (<frame> or <iframe>-like).
function getActualBoundingClientRect(node) {
var boundingRect = node.getBoundingClientRect();
// The original object returned by getBoundingClientRect is immutable, so we clone it
// We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
for (var k in boundingRect) {
rect[k] = boundingRect[k];
if (node.ownerDocument !== document) {
var _frameElement = node.ownerDocument.defaultView.frameElement;
var frameRect = getActualBoundingClientRect(_frameElement);
rect.top += frameRect.top;
rect.bottom += frameRect.top;
rect.left += frameRect.left;
rect.right += frameRect.left;
// Ignore "Access is denied" in IE11/Edge
function getScrollParents(el) {
// In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
var computedStyle = getComputedStyle(el) || {};
var position = computedStyle.position;
if (position === 'fixed') {
while ((parent = parent.parentNode) && parent && parent.nodeType === 1) {
style = getComputedStyle(parent);
if (typeof style === 'undefined' || style === null) {
var overflow = _style.overflow;
var overflowX = _style.overflowX;
var overflowY = _style.overflowY;
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) {
parents.push(el.ownerDocument.body);
// If the node is within a frame, account for the parent window scroll
if (el.ownerDocument !== document) {
parents.push(el.ownerDocument.defaultView);
var uniqueId = (function () {
var getOrigin = function getOrigin() {
// getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of
// jitter as the user scrolls that messes with our ability to detect if two positions
// are equivilant or not. We place an element at the top left of the page that will
// get the same jitter, so we can cancel the two out.
if (!node || !document.body.contains(node)) {
node = document.createElement('div');
node.setAttribute('data-tether-id', uniqueId());
document.body.appendChild(node);
var id = node.getAttribute('data-tether-id');
if (typeof zeroPosCache[id] === 'undefined') {
zeroPosCache[id] = getActualBoundingClientRect(node);
// Clear the cache when this position call is done
function removeUtilElements() {
document.body.removeChild(zeroElement);
el = document.documentElement;
var docEl = doc.documentElement;
var box = getActualBoundingClientRect(el);
var origin = getOrigin();
if (typeof box.width === 'undefined') {
box.width = document.body.scrollWidth - box.left - box.right;
if (typeof box.height === 'undefined') {
box.height = document.body.scrollHeight - box.top - box.bottom;
box.top = box.top - docEl.clientTop;
box.left = box.left - docEl.clientLeft;
box.right = doc.body.clientWidth - box.width - box.left;
box.bottom = doc.body.clientHeight - box.height - box.top;
function getOffsetParent(el) {
return el.offsetParent || document.documentElement;
var _scrollBarSize = null;
function getScrollBarSize() {
var inner = document.createElement('div');
inner.style.width = '100%';
inner.style.height = '200px';
var outer = document.createElement('div');
outer.appendChild(inner);
document.body.appendChild(outer);
var widthContained = inner.offsetWidth;
outer.style.overflow = 'scroll';
var widthScroll = inner.offsetWidth;
if (widthContained === widthScroll) {
widthScroll = outer.clientWidth;
document.body.removeChild(outer);
var width = widthContained - widthScroll;
_scrollBarSize = { width: width, height: width };
var out = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
Array.prototype.push.apply(args, arguments);
args.slice(1).forEach(function (obj) {
if (({}).hasOwnProperty.call(obj, key)) {
function removeClass(el, name) {
if (typeof el.classList !== 'undefined') {
name.split(' ').forEach(function (cls) {
el.classList.remove(cls);
var regex = new RegExp('(^| )' + name.split(' ').join('|') + '( |$)', 'gi');
var className = getClassName(el).replace(regex, ' ');
setClassName(el, className);
function addClass(el, name) {
if (typeof el.classList !== 'undefined') {
name.split(' ').forEach(function (cls) {
var cls = getClassName(el) + (' ' + name);
function hasClass(el, name) {
if (typeof el.classList !== 'undefined') {
return el.classList.contains(name);
var className = getClassName(el);
return new RegExp('(^| )' + name + '( |$)', 'gi').test(className);
function getClassName(el) {
// Can't use just SVGAnimatedString here since nodes within a Frame in IE have
// completely separately SVGAnimatedString base classes
if (el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString) {
return el.className.baseVal;
function setClassName(el, className) {
el.setAttribute('class', className);
function updateClasses(el, add, all) {
// Of the set of 'all' classes, we need the 'add' classes, and only the
// 'add' classes to be set.
all.forEach(function (cls) {
if (add.indexOf(cls) === -1 && hasClass(el, cls)) {
add.forEach(function (cls) {
if (!hasClass(el, cls)) {
var defer = function defer(fn) {
var flush = function flush() {
while (fn = deferred.pop()) {
var Evented = (function () {
_classCallCheck(this, Evented);
value: function on(event, handler, ctx) {
var once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
if (typeof this.bindings === 'undefined') {
if (typeof this.bindings[event] === 'undefined') {
this.bindings[event] = [];
this.bindings[event].push({ handler: handler, ctx: ctx, once: once });
value: function once(event, handler, ctx) {
this.on(event, handler, ctx, true);
value: function off(event, handler) {
if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') {
if (typeof handler === 'undefined') {
delete this.bindings[event];
while (i < this.bindings[event].length) {
if (this.bindings[event][i].handler === handler) {
this.bindings[event].splice(i, 1);
value: function trigger(event) {
if (typeof this.bindings !== 'undefined' && this.bindings[event]) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
while (i < this.bindings[event].length) {
var _bindings$event$i = this.bindings[event][i];
var handler = _bindings$event$i.handler;
var ctx = _bindings$event$i.ctx;
var once = _bindings$event$i.once;
if (typeof context === 'undefined') {
handler.apply(context, args);
this.bindings[event].splice(i, 1);
getActualBoundingClientRect: getActualBoundingClientRect,
getScrollParents: getScrollParents,
getOffsetParent: getOffsetParent,
removeClass: removeClass,
updateClasses: updateClasses,
getScrollBarSize: getScrollBarSize,
removeUtilElements: removeUtilElements
/* globals TetherBase, performance */
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x6, _x7, _x8) { var _again = true; _function: while (_again) { var object = _x6, property = _x7, receiver = _x8; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x6 = parent; _x7 = property; _x8 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
if (typeof TetherBase === 'undefined') {
throw new Error('You must include the utils.js file before tether.js');
var _TetherBase$Utils = TetherBase.Utils;
var getScrollParents = _TetherBase$Utils.getScrollParents;
var getBounds = _TetherBase$Utils.getBounds;
var getOffsetParent = _TetherBase$Utils.getOffsetParent;
var extend = _TetherBase$Utils.extend;
var addClass = _TetherBase$Utils.addClass;
var removeClass = _TetherBase$Utils.removeClass;
var updateClasses = _TetherBase$Utils.updateClasses;
var defer = _TetherBase$Utils.defer;
var flush = _TetherBase$Utils.flush;
var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
var removeUtilElements = _TetherBase$Utils.removeUtilElements;
var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
return a + diff >= b && b >= a - diff;
var transformKey = (function () {
if (typeof document === 'undefined') {
var el = document.createElement('div');
var transforms = ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
for (var i = 0; i < transforms.length; ++i) {
if (el.style[key] !== undefined) {
var position = function position() {
tethers.forEach(function (tether) {
if (typeof performance === 'object' && typeof performance.now === 'function') {
return performance.now();
var pendingTimeout = null;
var tick = function tick() {
if (typeof lastDuration !== 'undefined' && lastDuration > 16) {
// We voluntarily throttle ourselves if we can't manage 60fps
lastDuration = Math.min(lastDuration - 16, 250);
// Just in case this is the last event, remember to position just once more
pendingTimeout = setTimeout(tick, 250);