{"action":"created","issue":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/1838","repository_url":"https://api.github.com/repos/ampproject/amphtml","labels_url":"https://api.github.com/repos/ampproject/amphtml/issues/1838/labels{/name}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/1838/comments","events_url":"https://api.github.com/repos/ampproject/amphtml/issues/1838/events","html_url":"https://github.com/ampproject/amphtml/issues/1838","id":132119170,"number":1838,"title":"amp-ad viewability should be 0 with window not in focus","user":{"login":"giovanni-lovece-dm","id":16835502,"avatar_url":"https://avatars.githubusercontent.com/u/16835502?v=3","gravatar_id":"","url":"https://api.github.com/users/giovanni-lovece-dm","html_url":"https://github.com/giovanni-lovece-dm","followers_url":"https://api.github.com/users/giovanni-lovece-dm/followers","following_url":"https://api.github.com/users/giovanni-lovece-dm/following{/other_user}","gists_url":"https://api.github.com/users/giovanni-lovece-dm/gists{/gist_id}","starred_url":"https://api.github.com/users/giovanni-lovece-dm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giovanni-lovece-dm/subscriptions","organizations_url":"https://api.github.com/users/giovanni-lovece-dm/orgs","repos_url":"https://api.github.com/users/giovanni-lovece-dm/repos","events_url":"https://api.github.com/users/giovanni-lovece-dm/events{/privacy}","received_events_url":"https://api.github.com/users/giovanni-lovece-dm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-08T11:35:05Z","updated_at":"2016-02-08T16:07:59Z","closed_at":null,"body":"We are implementing viewability but we actually need that the ad has been in view for a certain amount of seconds (2 or 3 seconds). \r\n\r\nIf I get a change in the intersection stating that the height is, for example, the 80% of the ad I start a timeout and after _n_ seconds i register the viewability. At the moment if the user closes browser or changes tab, I'm not aware that my ad is not visible anymore.\r\n\r\nI think this can be solved in three ways: \r\n - trigger a changeIntersection with 0 when the window has loss focus and the correct height when the window gets the focus again;\r\n - expose a method into the iframe to check the actual height of intersection so, before we register viewability, we can check that the value is compliant with our needs (it should be 0 if window is not in focus)\r\n - expose a method to get a boolean whether the main window is in focus or not;\r\n\r\nWhat do you think about it?"},"comment":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/comments/181442665","html_url":"https://github.com/ampproject/amphtml/issues/1838#issuecomment-181442665","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/1838","id":181442665,"user":{"login":"cramforce","id":89679,"avatar_url":"https://avatars.githubusercontent.com/u/89679?v=3","gravatar_id":"","url":"https://api.github.com/users/cramforce","html_url":"https://github.com/cramforce","followers_url":"https://api.github.com/users/cramforce/followers","following_url":"https://api.github.com/users/cramforce/following{/other_user}","gists_url":"https://api.github.com/users/cramforce/gists{/gist_id}","starred_url":"https://api.github.com/users/cramforce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cramforce/subscriptions","organizations_url":"https://api.github.com/users/cramforce/orgs","repos_url":"https://api.github.com/users/cramforce/repos","events_url":"https://api.github.com/users/cramforce/events{/privacy}","received_events_url":"https://api.github.com/users/cramforce/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T16:07:59Z","updated_at":"2016-02-08T16:07:59Z","body":"Thought some more and 0 height is bad because some people use that for animations.\r\n\r\nWe will expose the visibility state similar to the page visibility API. I was actually working on that over the weekend."}}