mirror of
https://github.com/videojs/video.js.git
synced 2025-01-04 06:48:49 +02:00
fix: use performance.now() when possible (#5870)
This commit is contained in:
parent
c59ba5f465
commit
629594ece5
@ -1128,7 +1128,7 @@ class Component {
|
||||
pageY: event.touches[0].pageY
|
||||
};
|
||||
// Record start time so we can detect a tap vs. "touch and hold"
|
||||
touchStart = new Date().getTime();
|
||||
touchStart = window.performance.now();
|
||||
// Reset couldBeTap tracking
|
||||
couldBeTap = true;
|
||||
}
|
||||
@ -1166,7 +1166,7 @@ class Component {
|
||||
// Proceed only if the touchmove/leave/cancel event didn't happen
|
||||
if (couldBeTap === true) {
|
||||
// Measure how long the touch lasted
|
||||
const touchTime = new Date().getTime() - touchStart;
|
||||
const touchTime = window.performance.now() - touchStart;
|
||||
|
||||
// Make sure the touch was less than the threshold to be considered a tap
|
||||
if (touchTime < touchTimeThreshold) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
* @module dom-data
|
||||
*/
|
||||
import * as Guid from './guid.js';
|
||||
import window from 'global/window';
|
||||
|
||||
/**
|
||||
* Element Data Store.
|
||||
@ -23,7 +24,7 @@ export const elData = {};
|
||||
* @constant
|
||||
* @private
|
||||
*/
|
||||
const elIdAttr = 'vdata' + (new Date()).getTime();
|
||||
const elIdAttr = 'vdata' + Math.floor(window.performance && window.performance.now() || Date.now());
|
||||
|
||||
/**
|
||||
* Returns the cache object where data for an element is stored
|
||||
|
@ -61,10 +61,10 @@ export const bind = function(context, fn, uid) {
|
||||
* @return {Function}
|
||||
*/
|
||||
export const throttle = function(fn, wait) {
|
||||
let last = Date.now();
|
||||
let last = window.performance.now();
|
||||
|
||||
const throttled = function(...args) {
|
||||
const now = Date.now();
|
||||
const now = window.performance.now();
|
||||
|
||||
if (now - last >= wait) {
|
||||
fn(...args);
|
||||
|
Loading…
Reference in New Issue
Block a user