-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Enable listening for touch events above the player #992
Changes from 9 commits
07cd980
4b254a0
a7d624a
26c8d3f
e529484
44d6cac
4d2267c
75a2313
9975ed4
28a4d29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
vjs.MediaTechController = vjs.Component.extend({ | ||
/** @constructor */ | ||
init: function(player, options, ready){ | ||
// we don't want the tech to report user activity automatically. | ||
// This is done manually in addControlsListeners | ||
options.reportUserActivity = false; | ||
vjs.Component.call(this, player, options, ready); | ||
|
||
this.initControlsListeners(); | ||
|
@@ -60,7 +63,7 @@ vjs.MediaTechController.prototype.initControlsListeners = function(){ | |
}; | ||
|
||
vjs.MediaTechController.prototype.addControlsListeners = function(){ | ||
var preventBubble, userWasActive; | ||
var userWasActive; | ||
|
||
// Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do | ||
// trigger mousedown/up. | ||
|
@@ -82,23 +85,14 @@ vjs.MediaTechController.prototype.addControlsListeners = function(){ | |
this.on('touchstart', function(event) { | ||
// Stop the mouse events from also happening | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
// Record if the user was active now so we don't have to keep polling it | ||
userWasActive = this.player_.userActive(); | ||
}); | ||
|
||
preventBubble = function(event){ | ||
event.stopPropagation(); | ||
if (userWasActive) { | ||
this.player_.reportUserActivity(); | ||
this.on('touchmove', function(event) { | ||
if (userWasActive){ | ||
this.player().reportUserActivity(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not seeing it appear if I was moving my finger on the video. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok if the controls don't appear if they're already hidden when you do a touchmove (no tap), but if the controls are showing, we want the controls to keep showing for as long as the user is moving their finger around. Does that makes sense? I believe I was just trying mimic iOS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think they keep showing and don't disappear. I'll double check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like they don't. |
||
} | ||
}; | ||
|
||
// Treat all touch events the same for consistency | ||
this.on('touchmove', preventBubble); | ||
this.on('touchleave', preventBubble); | ||
this.on('touchcancel', preventBubble); | ||
this.on('touchend', preventBubble); | ||
}); | ||
|
||
// Turn on component tap events | ||
this.emitTapEvents(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want enableUserActivity to be the default for components, I think we want this to be
if (options.reportUserActivity !== false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Done.