Skip to content

Commit

Permalink
refactor: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Kuhrt committed Oct 4, 2017
1 parent eec9296 commit b572f65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ Defines the size of the tip pointer. Use .01 to disable tip. Defaults to '7'.

---

#### `appendTarget :: DOMNode`
#### `appendTarget :: DOMElement`

- The DOM node which this popover will be appended to. Defaults to 'document.body'.
- The DOM element which the https://reactjs.org/docs/portals.html[portal] will mount into. In effect the popover will become an appended child of this DOM element. Defaults to 'document.body'.
18 changes: 9 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import throttle from "lodash.throttle"
import * as cssVendor from "css-vendor"
import resizeEvent from "./on-resize"
import Layout from "./layout"
import { isServer, window, document } from "./platform"
import Platform from "./platform"
import Utils from "./utils"
import Tip from "./tip"

Expand Down Expand Up @@ -82,7 +82,7 @@ class Popover extends React.Component {
enterExitTransitionDurationMs: 500,
children: null,
refreshIntervalMs: 200,
appendTarget: isServer ? null : document.body
appendTarget: Platform.isClient ? Platform.document.body : null
}
constructor (props) {
super(props)
Expand Down Expand Up @@ -291,7 +291,7 @@ class Popover extends React.Component {
this.setState({ toggle: false })
}
enter () {
if (isServer) return
if (Platform.isServer) return
log("enter!")
this.trackPopover()
this.animateEnter()
Expand Down Expand Up @@ -355,7 +355,7 @@ class Popover extends React.Component {
be a nice feature in the future to allow other frames to be used
such as local elements that further constrain the popover`s world. */

this.frameEl = window
this.frameEl = Platform.window
this.hasTracked = true

/* Set a general interval for checking if target position changed. There is no way
Expand Down Expand Up @@ -383,8 +383,8 @@ class Popover extends React.Component {
/* Track user actions on the page. Anything that occurs _outside_ the Popover boundaries
should close the Popover. */

document.addEventListener("mousedown", this.checkForOuterAction)
document.addEventListener("touchstart", this.checkForOuterAction)
Platform.document.addEventListener("mousedown", this.checkForOuterAction)
Platform.document.addEventListener("touchstart", this.checkForOuterAction)

/* Kickstart layout at first boot. */

Expand All @@ -406,8 +406,8 @@ class Popover extends React.Component {
resizeEvent.off(this.frameEl, this.onFrameResize)
resizeEvent.off(this.containerEl, this.onPopoverResize)
resizeEvent.off(this.targetEl, this.onTargetResize)
document.removeEventListener("mousedown", this.checkForOuterAction)
document.removeEventListener("touchstart", this.checkForOuterAction)
Platform.document.removeEventListener("mousedown", this.checkForOuterAction)
Platform.document.removeEventListener("touchstart", this.checkForOuterAction)
this.hasTracked = false
}
onTargetResize = () => {
Expand Down Expand Up @@ -461,7 +461,7 @@ class Popover extends React.Component {
)
return [
<div key="1" ref={this.getTargetNodeRef}>{this.props.children}</div>,
!isServer && ReactDOM.createPortal(popover, this.props.appendTarget),
Platform.isClient && ReactDOM.createPortal(popover, this.props.appendTarget),
]
}
}
Expand Down

0 comments on commit b572f65

Please sign in to comment.