{"action":"created","issue":{"url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/12","repository_url":"https://api.github.com/repos/guardian/interactive-boot-scripts","labels_url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/12/comments","events_url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/12/events","html_url":"https://github.com/guardian/interactive-boot-scripts/pull/12","id":153761908,"number":12,"title":"Add visibility tracking","user":{"login":"joelochlann","id":5122968,"avatar_url":"https://avatars.githubusercontent.com/u/5122968?v=3","gravatar_id":"","url":"https://api.github.com/users/joelochlann","html_url":"https://github.com/joelochlann","followers_url":"https://api.github.com/users/joelochlann/followers","following_url":"https://api.github.com/users/joelochlann/following{/other_user}","gists_url":"https://api.github.com/users/joelochlann/gists{/gist_id}","starred_url":"https://api.github.com/users/joelochlann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelochlann/subscriptions","organizations_url":"https://api.github.com/users/joelochlann/orgs","repos_url":"https://api.github.com/users/joelochlann/repos","events_url":"https://api.github.com/users/joelochlann/events{/privacy}","received_events_url":"https://api.github.com/users/joelochlann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-09T12:07:31Z","updated_at":"2016-05-09T13:16:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/guardian/interactive-boot-scripts/pulls/12","html_url":"https://github.com/guardian/interactive-boot-scripts/pull/12","diff_url":"https://github.com/guardian/interactive-boot-scripts/pull/12.diff","patch_url":"https://github.com/guardian/interactive-boot-scripts/pull/12.patch"},"body":"We're using embedded interactives as part of some new membership feature tests, and we'd like to be able to track their visibility - i.e. whether enough of the element is in the viewport for long enough to be considered \"visible\".\r\n\r\nThis can't be tracked from within the iframe itself because it doesn't know about the size of the parent viewport, hence the changes needed to this boot script. The approach I've gone for is that the iframe will opt in to this visibility monitoring by sending a `monitor-visibility` message to the parent. (This message will be sent using the `iframeMessenger` - separate PR to come.) The parent then tells the iframe its initial visibility and sets up handlers to message it with an updated value if the visibility changes as a result of `scroll` or `resize` events.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/comments/217861047","html_url":"https://github.com/guardian/interactive-boot-scripts/pull/12#issuecomment-217861047","issue_url":"https://api.github.com/repos/guardian/interactive-boot-scripts/issues/12","id":217861047,"user":{"login":"wpf500","id":2084823,"avatar_url":"https://avatars.githubusercontent.com/u/2084823?v=3","gravatar_id":"","url":"https://api.github.com/users/wpf500","html_url":"https://github.com/wpf500","followers_url":"https://api.github.com/users/wpf500/followers","following_url":"https://api.github.com/users/wpf500/following{/other_user}","gists_url":"https://api.github.com/users/wpf500/gists{/gist_id}","starred_url":"https://api.github.com/users/wpf500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpf500/subscriptions","organizations_url":"https://api.github.com/users/wpf500/orgs","repos_url":"https://api.github.com/users/wpf500/repos","events_url":"https://api.github.com/users/wpf500/events{/privacy}","received_events_url":"https://api.github.com/users/wpf500/received_events","type":"User","site_admin":false},"created_at":"2016-05-09T13:16:46Z","updated_at":"2016-05-09T13:16:46Z","body":"I'm not sure why the `isVisible` variable is needed? It looks like it recalculates the value before it sends the message anyway.\r\n\r\nCould we just store the viewport dimensions on resize? I think then we could avoid the DOM on scroll events and avoid debouncing."}}