react-i13n
Advanced tools
Comparing version 2.0.13 to 2.1.0
@@ -28,2 +28,6 @@ /** | ||
* @param {Object} options.i13nNodeClass the i13nNode class, you can inherit it with your own functionalities | ||
* @param {String} options.scrollableContainerId id of the scrollable element that your components | ||
* reside within. Normally, you won't need to provide a value for this. This is only to | ||
* support viewport checking when your components are contained within a scrollable element. | ||
* Currently, only elements that fill the viewport are supported. | ||
* @constructor | ||
@@ -41,2 +45,3 @@ */ | ||
this._handlerTimeout = options.handlerTimeout || DEFAULT_HANDLER_TIMEOUT; | ||
this._scrollableContainerId = options.scrollableContainerId || undefined; | ||
@@ -165,2 +170,23 @@ // set itself to the global object so that we can get it anywhere by the static function getInstance | ||
/** | ||
* Get scrollableContainerId value | ||
* @method getScrollableContainerId | ||
* @return {String} scrollableContainerId value | ||
*/ | ||
ReactI13n.prototype.getScrollableContainerId = function getScrollableContainerId () { | ||
return this._scrollableContainerId; | ||
}; | ||
/** | ||
* Get scrollable container DOM node | ||
* @method getScrollableContainerDOMNode | ||
* @return {Object} scrollable container DOM node. This will be undefined if no | ||
* scrollableContainerId was set, or null if the element was not found in the DOM. | ||
*/ | ||
ReactI13n.prototype.getScrollableContainerDOMNode = function getScrollableContainerDOMNode () { | ||
if (this._scrollableContainerId) { | ||
return document && document.getElementById(this._scrollableContainerId); | ||
} | ||
}; | ||
/** | ||
* Get root i13n node | ||
@@ -187,4 +213,6 @@ * @method getRootI13nNode | ||
this._handlerTimeout = options.handlerTimeout ? options.handlerTimeout : this._handlerTimeout; | ||
this._scrollableContainerId = 'undefined' === typeof options.scrollableContainerId ? | ||
this._scrollableContainerId : options.scrollableContainerId; | ||
}; | ||
module.exports = ReactI13n; |
@@ -102,2 +102,3 @@ /** | ||
} | ||
var reactI13n = self._getReactI13n(); | ||
@@ -112,4 +113,11 @@ // bind the click event for i13n component if it's enabled | ||
// enable viewport checking if enabled | ||
if (self._getReactI13n().isViewportEnabled()) { | ||
self.subscribeViewportEvents(); | ||
if (reactI13n.isViewportEnabled()) { | ||
var options = {}; | ||
if (reactI13n.getScrollableContainerDOMNode) { | ||
var domNode = reactI13n.getScrollableContainerDOMNode(); | ||
if (domNode) { | ||
options.target = domNode; | ||
} | ||
} | ||
self.subscribeViewportEvents(options); | ||
self._enableViewportDetection(); | ||
@@ -116,0 +124,0 @@ } |
@@ -65,4 +65,4 @@ /** | ||
subscribeViewportEvents: function () { | ||
this.subscription = subscribe('scrollEnd', this._detectViewport); | ||
subscribeViewportEvents: function (options) { | ||
this.subscription = subscribe('scrollEnd', this._detectViewport, options || {}); | ||
}, | ||
@@ -69,0 +69,0 @@ |
@@ -143,3 +143,3 @@ // jscs:disable maximumLineLength | ||
mocha: { | ||
command: './node_modules/mocha/bin/mocha <%= project.tmp %>/<%= project.unit %> --require ./tests/setup --recursive --reporter spec' | ||
command: 'node ./node_modules/mocha/bin/mocha <%= project.tmp %>/<%= project.unit %> --require ./tests/setup --recursive --reporter spec' | ||
} | ||
@@ -146,0 +146,0 @@ }, |
{ | ||
"name": "react-i13n", | ||
"description": "React I13n provides a performant and scalable solution to application instrumentation.", | ||
"version": "2.0.13", | ||
"version": "2.1.0", | ||
"main": "index.js", | ||
@@ -19,3 +19,3 @@ "repository": { | ||
"setimmediate": "^1.0.2", | ||
"subscribe-ui-event": "^1.0.5" | ||
"subscribe-ui-event": "^1.0.7" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76290
1807
Updatedsubscribe-ui-event@^1.0.7