Skip to content

fix time calculation after a blur event - #77

Open
zvictor wants to merge 2 commits into
jasonzissman:masterfrom
zvictor:patch-1
Open

fix time calculation after a blur event#77
zvictor wants to merge 2 commits into
jasonzissman:masterfrom
zvictor:patch-1

Conversation

@zvictor

@zvictor zvictor commented Nov 12, 2022

Copy link
Copy Markdown

Problem

As reported at #41 and #59, TimeMe has a hard time to notice user activity after a blur event is triggered by activity on an iframe, such as Youtube/Vimeo embeds.

Diagnosis

This happens because the user can be navigating again on the parent page (scroll, mousemove, etc) even though the focus remains on the iframe. That won't change unless the user decides to click somewhere in the parent page.

Solution

In order to fix that, we need to start tracking time again as soon as the user shows activity on the parent page. TimeMe has to call TimeMe.triggerUserHasReturned whenever there is activity showing that the user has returned:

IF there is activity
BUT user is not on page
THEN triggerUserHasReturned()

as such:

userActivityDetected: () => {
  if (TimeMe.isUserCurrentlyIdle || !TimeMe.isUserCurrentlyOnPage) {
    TimeMe.triggerUserHasReturned();
  }
  TimeMe.resetIdleCountdown();
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant