Skip to content

Commit

Permalink
Merge pull request #307 from bokuweb/fix-auto
Browse files Browse the repository at this point in the history
fix: fix behavior when set auto
  • Loading branch information
bokuweb authored Jun 24, 2018
2 parents a64ba81 + cc76696 commit 2c1cf11
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,17 @@ export default class Resizable extends React.Component<ResizableProps, State> {
let width = 0;
let height = 0;
if (typeof window !== 'undefined') {
// HACK: Set position `relative` to get parent size
const orgWidth = this.resizable.offsetWidth;
const orgHeight = this.resizable.offsetHeight;
// HACK: Set position `relative` to get parent size.
// This is because when re-resizable set `absolute`, I can not get base width correctly.
const orgPosition = this.resizable.style.position;
if (orgPosition !== 'relative') {
this.resizable.style.position = 'relative';
}
width = this.resizable.offsetWidth;
height = this.resizable.offsetHeight;
// INFO: Use original width or height if set auto.
width = this.resizable.style.width !== 'auto' ? this.resizable.offsetWidth : orgWidth;
height = this.resizable.style.height !== 'auto' ? this.resizable.offsetHeight : orgHeight;
// Restore original position
this.resizable.style.position = orgPosition;
}
Expand Down

0 comments on commit 2c1cf11

Please sign in to comment.