nfl / react-gpt

A React display ad component using Google Publisher Tag
MIT License
145 stars 84 forks source link

Feature request: viewableThreshold above 1 #79

Open Fumler opened 6 years ago

Fumler commented 6 years ago

Hello.

Great library! Just wondering if there are any plans to allow viewableThreshold to be more than 1? We would like to start loading our ads a bit before they are actually in the viewport.

A solution could be to just wrap the ad in a lazyload component, but seeing as you already have the logic for checking if its in the viewport I thought it might be better to allow for it in your component.

What do you think?

potench commented 6 years ago

I believe it would need to be a different property since viewableThreshold is a measure of the area of the ad within the viewable area. We'd need to measure the proximity of the ad to the viewable area. And I'm wondering if there are other use cases for determining ad-load intent.

Check out https://github.com/nfl/react-gpt/blob/22437553b50272b8d6221ed29f98da76c912eabd/src/Bling.js#L502 This is calling isInViewport (https://github.com/nfl/react-gpt/blob/17c8b89a05209135968bb9a3447274524f1b5925/src/utils/isInViewport.js)
I think we can riff of this and the logic is pretty simple, but I'm not sure overloading viewableThreshold makes sense. Will come back with proposal later today.