UNPKG

@hzy1123581324/z-view-ui

Version:

z-view-ui是使用vue3开发的组件,开发中,有部分组件功能未实现,慎用

37 lines (32 loc) 1.24 kB
// console.log('43jalsdkfjalsdj alsdkjf alsdkjf asld '); var lastTime = 0 function overwriteCancelAnimationFrame(id) { clearTimeout(id) } function overwriteRequestAnimationFrame(callback, element) { // console.log('********j********') var currTime = new Date().getTime() // 为了使setTimteout的尽可能的接近每秒60帧的效果 var timeToCall = Math.max(0, 16 - (currTime - lastTime)) var id = window.setTimeout(function () { callback(currTime + timeToCall) }, timeToCall) lastTime = currTime + timeToCall return id } (function () { var vendors = ['ms', 'moz', 'webkit', 'o'] for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'] window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'] } if (!window.requestAnimationFrame) window.requestAnimationFrame = overwriteRequestAnimationFrame if (!window.cancelAnimationFrame) window.cancelAnimationFrame = overwriteCancelAnimationFrame })() export { overwriteRequestAnimationFrame as requestAnimationFrame, overwriteCancelAnimationFrame as cancelAnimationFrame }