Skip to content

Commit

Permalink
Fixed first best layout of popover
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand2489 committed Apr 16, 2019
1 parent 3c09dec commit f709cc6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
23 changes: 18 additions & 5 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var Popover = function (_React$Component) {
};

_this.state = {
standing: "above",
standing: "",
exited: !_this.props.isOpen, // for animation-dependent rendering, should popover close/open?
exiting: false, // for tracking in-progress animations
toggle: _this.props.isOpen || false // for business logic tracking, should popover close/open?
Expand Down Expand Up @@ -223,9 +223,21 @@ var Popover = function (_React$Component) {
way at any time for any arbitrary trigger. There may be value in investigating the
http://overconstrained.io community for its general layout system via the
constraint-solver Cassowary. */
};if (this.zone) this.size[this.zone.flow === "row" ? "h" : "w"] += this.props.tipSize;
var zone = _layout2.default.pickZone(pickerSettings, this.frameBounds, this.targetBounds, this.size);
if (this.zone) this.size[this.zone.flow === "row" ? "h" : "w"] -= this.props.tipSize;

};var zone = void 0;
var desiredPlace = this.props.preferPlace || this.props.place;
if (this.zone) {
this.size[this.zone.flow === "row" ? "h" : "w"] += this.props.tipSize;
if (!desiredPlace) {
zone = this.zone;
}
} else {
zone = _layout2.default.pickZone(pickerSettings, this.frameBounds, this.targetBounds, this.size);
}

if (this.zone) {
this.size[this.zone.flow === "row" ? "h" : "w"] -= this.props.tipSize;
}

var tb = this.targetBounds;
this.zone = zone;
Expand Down Expand Up @@ -384,6 +396,7 @@ var Popover = function (_React$Component) {
log("exit!");
this.animateExit();
this.untrackPopover();
this.zone = null;
}
}, {
key: "animateExitStop",
Expand Down Expand Up @@ -609,7 +622,7 @@ var Popover = function (_React$Component) {
Tip = _props.Tip;
var standing = this.state.standing;


standing = standing || "below";
var popoverProps = {
className: "Popover Popover-" + standing + " " + className,
style: _extends({}, coreStyle, style)
Expand Down
33 changes: 22 additions & 11 deletions source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Popover extends React.Component {
constructor(props) {
super(props)
this.state = {
standing: "above",
standing: "",
exited: !this.props.isOpen, // for animation-dependent rendering, should popover close/open?
exiting: false, // for tracking in-progress animations
toggle: this.props.isOpen || false, // for business logic tracking, should popover close/open?
Expand Down Expand Up @@ -147,16 +147,26 @@ class Popover extends React.Component {
way at any time for any arbitrary trigger. There may be value in investigating the
http://overconstrained.io community for its general layout system via the
constraint-solver Cassowary. */
if (this.zone)

let zone
const desiredPlace = this.props.preferPlace || this.props.place
if (this.zone) {
this.size[this.zone.flow === "row" ? "h" : "w"] += this.props.tipSize
const zone = Layout.pickZone(
pickerSettings,
this.frameBounds,
this.targetBounds,
this.size,
)
if (this.zone)
if (!desiredPlace) {
zone = this.zone
}
} else {
zone = Layout.pickZone(
pickerSettings,
this.frameBounds,
this.targetBounds,
this.size,
)
}

if (this.zone) {
this.size[this.zone.flow === "row" ? "h" : "w"] -= this.props.tipSize
}

const tb = this.targetBounds
this.zone = zone
Expand Down Expand Up @@ -322,6 +332,7 @@ class Popover extends React.Component {
log("exit!")
this.animateExit()
this.untrackPopover()
this.zone = null
}
animateExitStop() {
clearTimeout(this.exitingAnimationTimer1)
Expand Down Expand Up @@ -572,8 +583,8 @@ class Popover extends React.Component {
}
render() {
const { className = "", style = {}, tipSize, Tip } = this.props
const { standing } = this.state

let { standing } = this.state
standing = standing || "below"
const popoverProps = {
className: `Popover Popover-${standing} ${className}`,
style: { ...coreStyle, ...style },
Expand Down

0 comments on commit f709cc6

Please sign in to comment.