if (changeAttachX === 'target' || changeAttachX === 'both') {
if (left < bounds[0] && tAttachment.left === 'left') {
tAttachment.left = 'right';
if (left + width > bounds[2] && tAttachment.left === 'right') {
tAttachment.left = 'left';
if (changeAttachX === 'together') {
if (left < bounds[0] && tAttachment.left === 'left') {
if (eAttachment.left === 'right') {
tAttachment.left = 'right';
eAttachment.left = 'left';
} else if (eAttachment.left === 'left') {
tAttachment.left = 'right';
eAttachment.left = 'right';
} else if (left + width > bounds[2] && tAttachment.left === 'right') {
if (eAttachment.left === 'left') {
tAttachment.left = 'left';
eAttachment.left = 'right';
} else if (eAttachment.left === 'right') {
tAttachment.left = 'left';
eAttachment.left = 'left';
} else if (tAttachment.left === 'center') {
if (left + width > bounds[2] && eAttachment.left === 'left') {
eAttachment.left = 'right';
} else if (left < bounds[0] && eAttachment.left === 'right') {
eAttachment.left = 'left';
if (changeAttachY === 'element' || changeAttachY === 'both') {
if (top < bounds[1] && eAttachment.top === 'bottom') {
if (top + height > bounds[3] && eAttachment.top === 'top') {
eAttachment.top = 'bottom';
if (changeAttachX === 'element' || changeAttachX === 'both') {
if (eAttachment.left === 'right') {
eAttachment.left = 'left';
} else if (eAttachment.left === 'center') {
eAttachment.left = 'left';
if (left + width > bounds[2]) {
if (eAttachment.left === 'left') {
eAttachment.left = 'right';
} else if (eAttachment.left === 'center') {
eAttachment.left = 'right';
if (typeof pin === 'string') {
pin = pin.split(',').map(function (p) {
} else if (pin === true) {
pin = ['top', 'left', 'right', 'bottom'];
if (pin.indexOf('top') >= 0) {
if (top + height > bounds[3]) {
if (pin.indexOf('bottom') >= 0) {
top = bounds[3] - height;
if (pin.indexOf('left') >= 0) {
if (left + width > bounds[2]) {
if (pin.indexOf('right') >= 0) {
left = bounds[2] - width;
var pinnedClass = undefined;
if (typeof _this.options.pinnedClass !== 'undefined') {
pinnedClass = _this.options.pinnedClass;
pinnedClass = _this.getClass('pinned');
addClasses.push(pinnedClass);
pinned.forEach(function (side) {
addClasses.push(pinnedClass + '-' + side);
var oobClass = undefined;
if (typeof _this.options.outOfBoundsClass !== 'undefined') {
oobClass = _this.options.outOfBoundsClass;
oobClass = _this.getClass('out-of-bounds');
addClasses.push(oobClass);
oob.forEach(function (side) {
addClasses.push(oobClass + '-' + side);
if (pinned.indexOf('left') >= 0 || pinned.indexOf('right') >= 0) {
eAttachment.left = tAttachment.left = false;
if (pinned.indexOf('top') >= 0 || pinned.indexOf('bottom') >= 0) {
eAttachment.top = tAttachment.top = false;
if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) {
_this.updateAttachClasses(eAttachment, tAttachment);
_this.trigger('update', {
targetAttachment: tAttachment
if (!(_this.options.addTargetClasses === false)) {
updateClasses(_this.target, addClasses, allClasses);
updateClasses(_this.element, addClasses, allClasses);
return { top: top, left: left };
var _TetherBase$Utils = TetherBase.Utils;
var getBounds = _TetherBase$Utils.getBounds;
var updateClasses = _TetherBase$Utils.updateClasses;
var defer = _TetherBase$Utils.defer;
TetherBase.modules.push({
position: function position(_ref) {
var _cache = this.cache('element-bounds', function () {
return getBounds(_this.element);
var height = _cache.height;
var width = _cache.width;
var targetPos = this.getTargetBounds();
var bottom = top + height;
var right = left + width;
if (top <= targetPos.bottom && bottom >= targetPos.top) {
['left', 'right'].forEach(function (side) {
var targetPosSide = targetPos[side];
if (targetPosSide === left || targetPosSide === right) {
if (left <= targetPos.right && right >= targetPos.left) {
['top', 'bottom'].forEach(function (side) {
var targetPosSide = targetPos[side];
if (targetPosSide === top || targetPosSide === bottom) {
var sides = ['left', 'top', 'right', 'bottom'];
allClasses.push(this.getClass('abutted'));
sides.forEach(function (side) {
allClasses.push(_this.getClass('abutted') + '-' + side);
addClasses.push(this.getClass('abutted'));
abutted.forEach(function (side) {
addClasses.push(_this.getClass('abutted') + '-' + side);
if (!(_this.options.addTargetClasses === false)) {
updateClasses(_this.target, addClasses, allClasses);
updateClasses(_this.element, addClasses, allClasses);
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'); } }; })();
TetherBase.modules.push({
position: function position(_ref) {
if (!this.options.shift) {
var shift = this.options.shift;
if (typeof this.options.shift === 'function') {
shift = this.options.shift.call(this, { top: top, left: left });
var shiftTop = undefined,
if (typeof shift === 'string') {
shift = shift.split(' ');
shift[1] = shift[1] || shift[0];
var _shift2 = _slicedToArray(_shift, 2);
shiftTop = parseFloat(shiftTop, 10);
shiftLeft = parseFloat(shiftLeft, 10);
return { top: top, left: left };