Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an option to disable moving tethered element to the body #96

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.0.3",
"version": "1.1.0",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tether",
"repo": "HubSpot/tether",
"version": "1.0.3",
"version": "1.1.0",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
18 changes: 9 additions & 9 deletions dist/js/tether.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! tether 1.0.3 */
/*! tether 1.1.0 */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -182,7 +182,7 @@ function getScrollBarSize() {
}

function extend() {
var out = arguments[0] === undefined ? {} : arguments[0];
var out = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

var args = [];

Expand Down Expand Up @@ -285,7 +285,7 @@ var Evented = (function () {
_createClass(Evented, [{
key: 'on',
value: function on(event, handler, ctx) {
var once = arguments[3] === undefined ? false : arguments[3];
var once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];

if (typeof this.bindings === 'undefined') {
this.bindings = {};
Expand Down Expand Up @@ -397,7 +397,7 @@ var flush = _TetherBase$Utils.flush;
var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;

function within(a, b) {
var diff = arguments[2] === undefined ? 1 : arguments[2];
var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];

return a + diff >= b && b >= a - diff;
}
Expand Down Expand Up @@ -590,7 +590,7 @@ var TetherClass = (function () {
_createClass(TetherClass, [{
key: 'getClass',
value: function getClass() {
var key = arguments[0] === undefined ? '' : arguments[0];
var key = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
var classes = this.options.classes;

if (typeof classes !== 'undefined' && classes[key]) {
Expand All @@ -606,7 +606,7 @@ var TetherClass = (function () {
value: function setOptions(options) {
var _this2 = this;

var pos = arguments[1] === undefined ? true : arguments[1];
var pos = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];

var defaults = {
offset: '0 0',
Expand Down Expand Up @@ -788,7 +788,7 @@ var TetherClass = (function () {
}, {
key: 'enable',
value: function enable() {
var pos = arguments[0] === undefined ? true : arguments[0];
var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];

if (!(this.options.addTargetClasses === false)) {
addClass(this.target, this.getClass('enabled'));
Expand Down Expand Up @@ -887,7 +887,7 @@ var TetherClass = (function () {
value: function position() {
var _this5 = this;

var flushChanges = arguments[0] === undefined ? true : arguments[0];
var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];

// flushChanges commits the changes immediately, leave true unless you are positioning multiple
// tethers (in which case call Tether.Utils.flush yourself when you're done)
Expand Down Expand Up @@ -1165,7 +1165,7 @@ var TetherClass = (function () {
transcribe({ top: true, left: true }, pos.page);
}

if (!moved && this.element.parentNode.tagName !== 'BODY') {
if (this.options.moveRoot !== false && !moved && this.element.parentNode.tagName !== 'BODY') {
this.element.parentNode.removeChild(this.element);
document.body.appendChild(this.element);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tether.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.0.3",
"version": "1.1.0",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class TetherClass {
transcribe({top: true, left: true}, pos.page);
}

if(!moved && this.element.parentNode.tagName !== 'BODY') {
if(this.options.moveRoot !== false && !moved && this.element.parentNode.tagName !== 'BODY') {
this.element.parentNode.removeChild(this.element);
document.body.appendChild(this.element);
}
Expand Down