Skip to content

Commit

Permalink
use subscribe-ui-event
Browse files Browse the repository at this point in the history
  • Loading branch information
kaesonho committed Sep 2, 2015
1 parent c88b64f commit f758ff1
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 149 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,7 +15,7 @@ Typically, you have to manually add instrumentation code throughout your applica
* **Pluggable** - A pluggable interface lets you integrate any data analytics library (i.e. Google Analytics, Segment, etc). Take a look at the [available plugins](#available-plugins).
* **Performant** - Tracking data (`i13nModel`) can be a plain JS object or custom function. This means you can [dynamically change tracking data](./docs/guides/integrateWithComponents.md#dynamic-i13n-model) without causing unnecessary re-renders.
* **Adaptable** - If you are using an isomorphic framework (e.g. [Fluxible](http://fluxible.io)) to build your app, you can easily [change the tracking implementation](./docs/guides/createPlugins.md) on the server and client side. For example, to track page views, you can fire an http request on server and xhr request on the client.
* **Optimizable** - We provide an option to enable viewport checking for each `I13nNode`. Which means that data will only be beaconed when the node is in the viewport. This reduces the network usage for the user and provides better tracking details.
* **Optimizable** - We provide an option to enable viewport (integrating [subscribe-ui-event](https://github.com/yahoo/subscribe-ui-event)) checking for each `I13nNode`. Which means that data will only be beaconed when the node is in the viewport. This reduces the network usage for the user and provides better tracking details.
* **Auto Scan Links** - Support [auto scan links](./docs/api/createI13nNode.md) for the cases you are not able to replace the component you are using to get it tracked, e.g., if you have dependencies or you are using `dangerouslySetInnerHTML`. We scan the tags you define on client side, track them and build nodes for them in i13n tree.

## Install
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -14,11 +14,11 @@
},
"dependencies": {
"debug": "^2.1.3",
"eventemitter3": "^1.0.0",
"hoist-non-react-statics": "^1.0.0",
"object-assign": "^4.0.0",
"promise": "^7.0.1",
"setimmediate": "^1.0.2"
"setimmediate": "^1.0.2",
"subscribe-ui-event": "^0.2.2"
},
"devDependencies": {
"coveralls": "^2.11.1",
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/I13nMixin.js
Expand Up @@ -316,7 +316,7 @@ var I13nMixin = {
_recursiveDetectViewport: function () {
var self = this;
// detect viewport from the root, and skip all children's detection if it's not in the viewport
self._detectViewport(function detectCallback () {
self._detectViewport(null, null, function detectCallback () {
if (self._i13nNode.isInViewport()) {
self._i13nNode.getChildrenNodes().forEach(function detectChildrenViewport (childNode) {
var reactComponent = childNode.getReactComponent();
Expand Down
3 changes: 0 additions & 3 deletions src/mixins/viewport/EventEmitter.js

This file was deleted.

31 changes: 0 additions & 31 deletions src/mixins/viewport/MessageMixin.js

This file was deleted.

17 changes: 5 additions & 12 deletions src/mixins/viewport/ViewportMixin.js
Expand Up @@ -6,18 +6,11 @@
'use strict';

var React = require('react/addons');

var MsgMixin = require('./MessageMixin');

if (typeof window !== 'undefined') {
require('./scroll');
require('./visibility');
}
var subscribe = require('subscribe-ui-event').subscribe;

/* Viewport mixin assumes you are on browser and already have the scroll lib */
var Viewport = {
mixins: [MsgMixin],


propTypes: {
viewport: React.PropTypes.shape({
margins: React.PropTypes.shape({
Expand Down Expand Up @@ -53,7 +46,7 @@ var Viewport = {
callback && callback();
},

_detectViewport: function (callback) {
_detectViewport: function (err, payload, callback) {
var self = this;
if (!self.isMounted()) {
return;
Expand All @@ -75,11 +68,11 @@ var Viewport = {
},

subscribeViewportEvents: function () {
this.subscribe('scroll', this._detectViewport);
this.subscription = subscribe('scrollEnd', this._detectViewport);
},

unsubscribeViewportEvents: function () {
this.unsubscribe('scroll');
this.subscription.unsubscribe();
},

onEnterViewport: function (callback) {
Expand Down
36 changes: 0 additions & 36 deletions src/mixins/viewport/scroll.js

This file was deleted.

63 changes: 0 additions & 63 deletions src/mixins/viewport/visibility.js

This file was deleted.

0 comments on commit f758ff1

Please sign in to comment.