Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use subscribe-ui-event #45

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.