Skip to content

Commit

Permalink
Merge pull request #54 from rambler-digital-solutions/empty-click-thr…
Browse files Browse the repository at this point in the history
…ough

fix: ignore `pauseOnAdClick` on non-clickable ad
  • Loading branch information
andrepolischuk authored Jul 6, 2022
2 parents e918d9c + 3e9d384 commit 3929f2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/adUnit/VpaidAdUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class VpaidAdUnit extends VideoAdUnit {
evtHandler: {
[adClickThru]: (url, id, playerHandles) => {
if (playerHandles) {
if (this.paused() && this.pauseOnAdClick) {
const clickThroughUrl = typeof url === 'string' && url.length > 0 ? url : getClickThrough(this.vastChain[0].ad);

if (this.paused() && (this.pauseOnAdClick || !clickThroughUrl)) {
this.resume();
} else {
const clickThroughUrl = typeof url === 'string' && url.length > 0 ? url : getClickThrough(this.vastChain[0].ad);

if (this.pauseOnAdClick) {
this.pause();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ test('onClickThrough must on anchor second click, play the video and not call th

test('onClickThrough must on anchor every click, not pause the video and call the callback with clickthrough', () => {
const {element, videoElement} = videoAdContainer;
const clickThroughUrl = 'http://test.example.com/clickThroughUrl';

onClickThrough(videoAdContainer, callback, {pauseOnAdClick: false});
onClickThrough(videoAdContainer, callback, {
clickThroughUrl,
pauseOnAdClick: false
});

const anchor = element.querySelector('a.mol-vast-clickthrough');

Expand All @@ -114,8 +118,12 @@ test('onClickThrough must on anchor every click, not pause the video and call th

test('onClickThrough must on anchor every click, not play the video and call the callback with clickthrough', () => {
const {element, videoElement} = videoAdContainer;
const clickThroughUrl = 'http://test.example.com/clickThroughUrl';

onClickThrough(videoAdContainer, callback, {pauseOnAdClick: false});
onClickThrough(videoAdContainer, callback, {
clickThroughUrl,
pauseOnAdClick: false
});

const anchor = element.querySelector('a.mol-vast-clickthrough');

Expand Down
2 changes: 1 addition & 1 deletion src/adUnit/helpers/metrics/handlers/onClickThrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const onClickThrough = ({videoElement, element}, callback, {clickThroughUrl, pau
event.stopPropagation();
}

if (videoElement.paused && pauseOnAdClick) {
if (videoElement.paused && (pauseOnAdClick || !clickThroughUrl)) {
if (Event.prototype.preventDefault !== undefined) {
event.preventDefault();
}
Expand Down

0 comments on commit 3929f2b

Please sign in to comment.