diff --git a/src/adUnit/VpaidAdUnit.js b/src/adUnit/VpaidAdUnit.js index 6022089a..131787f6 100644 --- a/src/adUnit/VpaidAdUnit.js +++ b/src/adUnit/VpaidAdUnit.js @@ -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(); } diff --git a/src/adUnit/helpers/metrics/handlers/__tests__/onClickThrough.spec.js b/src/adUnit/helpers/metrics/handlers/__tests__/onClickThrough.spec.js index b368aff6..6b8a4aed 100644 --- a/src/adUnit/helpers/metrics/handlers/__tests__/onClickThrough.spec.js +++ b/src/adUnit/helpers/metrics/handlers/__tests__/onClickThrough.spec.js @@ -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'); @@ -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'); diff --git a/src/adUnit/helpers/metrics/handlers/onClickThrough.js b/src/adUnit/helpers/metrics/handlers/onClickThrough.js index 485a50ae..da90422d 100644 --- a/src/adUnit/helpers/metrics/handlers/onClickThrough.js +++ b/src/adUnit/helpers/metrics/handlers/onClickThrough.js @@ -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(); }