Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the bug when emit('stop') the requestAnimationFrame callback still run #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@
// it seems all handled in the tracking.TrackerTask..
// so in short, remove the tracking.TrackerTask from here
// if the user want to use it, it can create it himself
var requestId;
var stopRequestAnimationFrame = false;
var requestAnimationFrame_ = function() {
requestId = window.requestAnimationFrame(function() {
window.requestAnimationFrame(function() {
if (stopRequestAnimationFrame) return;
if (element.readyState === element.HAVE_ENOUGH_DATA) {
try {
// Firefox v~30.0 gets confused with the video readyState firing an
Expand All @@ -263,7 +264,7 @@

var task = new tracking.TrackerTask(tracker);
task.on('stop', function() {
window.cancelAnimationFrame(requestId);
stopRequestAnimationFrame = true;
});
task.on('run', function() {
requestAnimationFrame_();
Expand Down