Skip to content

Commit

Permalink
transpiled files and bumped version (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanauati authored Apr 26, 2019
1 parent 049451d commit be6089e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
15 changes: 15 additions & 0 deletions lib/adslot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function (_React$Component) {
_this.slotShouldRefresh = _this.slotShouldRefresh.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.slotRenderEnded = _this.slotRenderEnded.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.slotIsViewable = _this.slotIsViewable.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.slotVisibilityChanged = _this.slotVisibilityChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.state = {
slotId: _this.props.slotId || null
};
Expand Down Expand Up @@ -124,6 +125,8 @@ function (_React$Component) {
_manager.default.attachSlotRenderEnded(this.slotRenderEnded);

_manager.default.attachSlotIsViewable(this.slotIsViewable);

_manager.default.attachSlotVisibilityChanged(this.slotVisibilityChanged);
}
}, {
key: "registerSlot",
Expand All @@ -144,6 +147,8 @@ function (_React$Component) {
_manager.default.detachSlotRenderEnded(this.slotRenderEnded);

_manager.default.detachSlotIsViewable(this.slotIsViewable);

_manager.default.detachSlotVisibilityChanged(this.slotVisibilityChanged);
}
}, {
key: "slotRenderEnded",
Expand All @@ -163,6 +168,15 @@ function (_React$Component) {
}
}
}
}, {
key: "slotVisibilityChanged",
value: function slotVisibilityChanged(eventData) {
if (eventData.slotId === this.getSlotId()) {
if (this.props.onSlotVisibilityChanged !== undefined) {
this.props.onSlotVisibilityChanged(eventData);
}
}
}
}, {
key: "slotShouldRefresh",
value: function slotShouldRefresh() {
Expand Down Expand Up @@ -210,6 +224,7 @@ _defineProperty(AdSlot, "propTypes", {
targetingArguments: _propTypes.default.object,
onSlotRender: _propTypes.default.func,
onSlotIsViewable: _propTypes.default.func,
onSlotVisibilityChanged: _propTypes.default.func,
shouldRefresh: _propTypes.default.func,
slotId: _propTypes.default.string
});
Expand Down
14 changes: 14 additions & 0 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ var DFPManager = Object.assign(new _events.EventEmitter().setMaxListeners(0), {
event: event
});
});
pubadsService.addEventListener('slotVisibilityChanged', function (event) {
var slotId = event.slot.getSlotElementId();

_this.emit('slotVisibilityChanged', {
slotId: slotId,
event: event
});
});
pubadsService.setRequestNonPersonalizedAds(_this.personalizedAdsEnabled() ? 0 : 1);

var targetingArguments = _this.getTargetingArguments(); // set global targetting arguments
Expand Down Expand Up @@ -423,6 +431,12 @@ var DFPManager = Object.assign(new _events.EventEmitter().setMaxListeners(0), {
detachSlotRenderEnded: function detachSlotRenderEnded(cb) {
this.removeListener('slotRenderEnded', cb);
},
attachSlotVisibilityChanged: function attachSlotVisibilityChanged(cb) {
this.on('slotVisibilityChanged', cb);
},
detachSlotVisibilityChanged: function detachSlotVisibilityChanged(cb) {
this.removeListener('slotVisibilityChanged', cb);
},
attachSlotIsViewable: function attachSlotIsViewable(cb) {
this.on('impressionViewable', cb);
},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-dfp",
"version": "0.11.1",
"version": "0.11.2",
"homepage": "https://github.com/jaanauati/react-dfp/",
"author": {
"name": "Jonatan Alexis Anauati",
Expand Down

0 comments on commit be6089e

Please sign in to comment.