bee-affix
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -69,4 +69,7 @@ 'use strict'; | ||
_this.getContainerDOM = function () { | ||
var container = _this.props.container; | ||
_this.getContainerDOM = function (nextProps) { | ||
var container = nextProps ? nextProps.container : _this.props.container; | ||
if (!container) { | ||
return document.body; | ||
} | ||
if (container != document.body) { | ||
@@ -78,4 +81,4 @@ return _reactDom2["default"].findDOMNode(container); | ||
_this.getInitPosition = function () { | ||
var container = _this.getContainerDOM(); | ||
_this.getInitPosition = function (nextProps) { | ||
var container = _this.getContainerDOM(nextProps); | ||
var thisElm = _reactDom2["default"].findDOMNode(_this); | ||
@@ -107,3 +110,3 @@ | ||
_this.handleTargetChange = function (evt) { | ||
_this.handleTargetChange = function (evt, type) { | ||
var container = _this.getContainerDOM(); //是body | ||
@@ -138,3 +141,3 @@ | ||
_this.props.onTargetChange(_this.state); | ||
// this.getInitPosition(); | ||
type === 'resize' && _this.getInitPosition(); | ||
}; | ||
@@ -185,11 +188,17 @@ | ||
Affix.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
this.getInitPosition(); | ||
this.getInitPosition(nextProps); | ||
}; | ||
Affix.prototype.componentDidMount = function componentDidMount() { | ||
var _this2 = this; | ||
this.getInitPosition(); | ||
var listenTarget = this.props.target(); | ||
if (listenTarget) { | ||
listenTarget.addEventListener('resize', this.handleTargetChange); | ||
listenTarget.addEventListener('scroll', this.handleTargetChange); | ||
listenTarget.addEventListener('resize', function (e) { | ||
return _this2.handleTargetChange(e, 'resize'); | ||
}); | ||
listenTarget.addEventListener('scroll', function (e) { | ||
return _this2.handleTargetChange(e, 'scroll'); | ||
}); | ||
} | ||
@@ -199,6 +208,12 @@ }; | ||
Affix.prototype.componentWillUnmount = function componentWillUnmount() { | ||
var _this3 = this; | ||
var listenTarget = this.props.target(); | ||
if (listenTarget) { | ||
listenTarget.removeEventListener('scroll', this.handleTargetChange); | ||
listenTarget.removeEventListener('resize', this.handleTargetChange); | ||
listenTarget.addEventListener('resize', function (e) { | ||
return _this3.handleTargetChange(e, 'resize'); | ||
}); | ||
listenTarget.addEventListener('scroll', function (e) { | ||
return _this3.handleTargetChange(e, 'scroll'); | ||
}); | ||
} | ||
@@ -205,0 +220,0 @@ }; |
{ | ||
"name": "bee-affix", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Affix ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1040691
10807
0