dtd
Version:
根据数梦工场视觉规范打造的组件库,感谢react-components和ant design
1 lines • 866 B
JavaScript
import _toConsumableArray from"babel-runtime/helpers/toConsumableArray";import getRequestAnimationFrame,{cancelRequestAnimationFrame}from"../_util/getRequestAnimationFrame";var reqAnimFrame=getRequestAnimationFrame();export default function throttleByAnimationFrame(t){var e=void 0,r=function(){for(var r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];null==e&&(e=reqAnimFrame(function(r){return function(){e=null,t.apply(void 0,_toConsumableArray(r))}}(n)))};return r.cancel=function(){return cancelRequestAnimationFrame(e)},r};export function throttleByAnimationFrameDecorator(){return function(t,e,r){var n=r.value,a=!1;return{configurable:!0,get:function(){if(a||this===t.prototype||this.hasOwnProperty(e))return n;var r=throttleByAnimationFrame(n.bind(this));return a=!0,Object.defineProperty(this,e,{value:r,configurable:!0,writable:!0}),a=!1,r}}}};