Skip to content

Commit

Permalink
fix getting element's offsetLeft when it is absolutely positioned
Browse files Browse the repository at this point in the history
  • Loading branch information
Theadd committed May 9, 2015
1 parent 70a3600 commit c8e1703
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions addons.js
Expand Up @@ -2017,7 +2017,7 @@ var TabGroup = React.createClass({

var node = this.getDOMNode(),
tabWidth = node.offsetWidth / this.tabKeys.length,
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth),
targetKey = this.tabKeys[index] || false;

Expand Down Expand Up @@ -2049,7 +2049,7 @@ var TabGroup = React.createClass({
this._index = false;
this.handler.setParentOfToken(this.memberId);
} else {
var distance = e.pageX - this.getDOMNode().offsetLeft;
var distance = e.pageX - this.getDOMNode().getBoundingClientRect().left;
nextIndex = parseInt(distance / this.tabWidth);
}

Expand Down Expand Up @@ -2085,7 +2085,7 @@ var TabGroup = React.createClass({
var node = this.getDOMNode(),
numTabsMod = this.ctx.ownerId == this.memberId ? 0 : 1,
tabWidth = node.offsetWidth / (this.tabKeys.length + numTabsMod),
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth);

this.tabWidth = tabWidth;
Expand Down
6 changes: 3 additions & 3 deletions dist/react-panels-with-addons.js
Expand Up @@ -2017,7 +2017,7 @@ var TabGroup = React.createClass({

var node = this.getDOMNode(),
tabWidth = node.offsetWidth / this.tabKeys.length,
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth),
targetKey = this.tabKeys[index] || false;

Expand Down Expand Up @@ -2049,7 +2049,7 @@ var TabGroup = React.createClass({
this._index = false;
this.handler.setParentOfToken(this.memberId);
} else {
var distance = e.pageX - this.getDOMNode().offsetLeft;
var distance = e.pageX - this.getDOMNode().getBoundingClientRect().left;
nextIndex = parseInt(distance / this.tabWidth);
}

Expand Down Expand Up @@ -2085,7 +2085,7 @@ var TabGroup = React.createClass({
var node = this.getDOMNode(),
numTabsMod = this.ctx.ownerId == this.memberId ? 0 : 1,
tabWidth = node.offsetWidth / (this.tabKeys.length + numTabsMod),
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth);

this.tabWidth = tabWidth;
Expand Down
4 changes: 2 additions & 2 deletions dist/react-panels-with-addons.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-panels-with-addons.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/react-panels.js
Expand Up @@ -2017,7 +2017,7 @@ var TabGroup = React.createClass({

var node = this.getDOMNode(),
tabWidth = node.offsetWidth / this.tabKeys.length,
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth),
targetKey = this.tabKeys[index] || false;

Expand Down Expand Up @@ -2049,7 +2049,7 @@ var TabGroup = React.createClass({
this._index = false;
this.handler.setParentOfToken(this.memberId);
} else {
var distance = e.pageX - this.getDOMNode().offsetLeft;
var distance = e.pageX - this.getDOMNode().getBoundingClientRect().left;
nextIndex = parseInt(distance / this.tabWidth);
}

Expand Down Expand Up @@ -2085,7 +2085,7 @@ var TabGroup = React.createClass({
var node = this.getDOMNode(),
numTabsMod = this.ctx.ownerId == this.memberId ? 0 : 1,
tabWidth = node.offsetWidth / (this.tabKeys.length + numTabsMod),
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth);

this.tabWidth = tabWidth;
Expand Down
4 changes: 2 additions & 2 deletions dist/react-panels.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-panels.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -2017,7 +2017,7 @@ var TabGroup = React.createClass({

var node = this.getDOMNode(),
tabWidth = node.offsetWidth / this.tabKeys.length,
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth),
targetKey = this.tabKeys[index] || false;

Expand Down Expand Up @@ -2049,7 +2049,7 @@ var TabGroup = React.createClass({
this._index = false;
this.handler.setParentOfToken(this.memberId);
} else {
var distance = e.pageX - this.getDOMNode().offsetLeft;
var distance = e.pageX - this.getDOMNode().getBoundingClientRect().left;
nextIndex = parseInt(distance / this.tabWidth);
}

Expand Down Expand Up @@ -2085,7 +2085,7 @@ var TabGroup = React.createClass({
var node = this.getDOMNode(),
numTabsMod = this.ctx.ownerId == this.memberId ? 0 : 1,
tabWidth = node.offsetWidth / (this.tabKeys.length + numTabsMod),
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth);

this.tabWidth = tabWidth;
Expand Down
6 changes: 3 additions & 3 deletions src/jsx/tab.js
Expand Up @@ -73,7 +73,7 @@ var TabGroup = React.createClass({

var node = this.getDOMNode(),
tabWidth = node.offsetWidth / this.tabKeys.length,
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth),
targetKey = this.tabKeys[index] || false;

Expand Down Expand Up @@ -105,7 +105,7 @@ var TabGroup = React.createClass({
this._index = false;
this.handler.setParentOfToken(this.memberId);
} else {
var distance = e.pageX - this.getDOMNode().offsetLeft;
var distance = e.pageX - this.getDOMNode().getBoundingClientRect().left;
nextIndex = parseInt(distance / this.tabWidth);
}

Expand Down Expand Up @@ -141,7 +141,7 @@ var TabGroup = React.createClass({
var node = this.getDOMNode(),
numTabsMod = this.ctx.ownerId == this.memberId ? 0 : 1,
tabWidth = node.offsetWidth / (this.tabKeys.length + numTabsMod),
distance = e.pageX - node.offsetLeft,
distance = e.pageX - node.getBoundingClientRect().left,
index = parseInt(distance / tabWidth);

this.tabWidth = tabWidth;
Expand Down

0 comments on commit c8e1703

Please sign in to comment.