962c269496f191629d51c5ca520dd631.json
2.99 KB
{"ast":null,"code":"import React from 'react';\nexport default (function (callback, buffer) {\n var calledRef = React.useRef(false);\n var timeoutRef = React.useRef(null);\n\n function cancelTrigger() {\n window.clearTimeout(timeoutRef.current);\n }\n\n function trigger(force) {\n if (!calledRef.current || force === true) {\n if (callback() === false) {\n // Not delay since callback cancelled self\n return;\n }\n\n calledRef.current = true;\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n }, buffer);\n } else {\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n trigger();\n }, buffer);\n }\n }\n\n return [trigger, function () {\n calledRef.current = false;\n cancelTrigger();\n }];\n});","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-align/es/hooks/useBuffer.js"],"names":["React","callback","buffer","calledRef","useRef","timeoutRef","cancelTrigger","window","clearTimeout","current","trigger","force","setTimeout"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,gBAAgB,UAAUC,QAAV,EAAoBC,MAApB,EAA4B;AAC1C,MAAIC,SAAS,GAAGH,KAAK,CAACI,MAAN,CAAa,KAAb,CAAhB;AACA,MAAIC,UAAU,GAAGL,KAAK,CAACI,MAAN,CAAa,IAAb,CAAjB;;AAEA,WAASE,aAAT,GAAyB;AACvBC,IAAAA,MAAM,CAACC,YAAP,CAAoBH,UAAU,CAACI,OAA/B;AACD;;AAED,WAASC,OAAT,CAAiBC,KAAjB,EAAwB;AACtB,QAAI,CAACR,SAAS,CAACM,OAAX,IAAsBE,KAAK,KAAK,IAApC,EAA0C;AACxC,UAAIV,QAAQ,OAAO,KAAnB,EAA0B;AACxB;AACA;AACD;;AAEDE,MAAAA,SAAS,CAACM,OAAV,GAAoB,IAApB;AACAH,MAAAA,aAAa;AACbD,MAAAA,UAAU,CAACI,OAAX,GAAqBF,MAAM,CAACK,UAAP,CAAkB,YAAY;AACjDT,QAAAA,SAAS,CAACM,OAAV,GAAoB,KAApB;AACD,OAFoB,EAElBP,MAFkB,CAArB;AAGD,KAXD,MAWO;AACLI,MAAAA,aAAa;AACbD,MAAAA,UAAU,CAACI,OAAX,GAAqBF,MAAM,CAACK,UAAP,CAAkB,YAAY;AACjDT,QAAAA,SAAS,CAACM,OAAV,GAAoB,KAApB;AACAC,QAAAA,OAAO;AACR,OAHoB,EAGlBR,MAHkB,CAArB;AAID;AACF;;AAED,SAAO,CAACQ,OAAD,EAAU,YAAY;AAC3BP,IAAAA,SAAS,CAACM,OAAV,GAAoB,KAApB;AACAH,IAAAA,aAAa;AACd,GAHM,CAAP;AAID,CAjCD","sourcesContent":["import React from 'react';\nexport default (function (callback, buffer) {\n var calledRef = React.useRef(false);\n var timeoutRef = React.useRef(null);\n\n function cancelTrigger() {\n window.clearTimeout(timeoutRef.current);\n }\n\n function trigger(force) {\n if (!calledRef.current || force === true) {\n if (callback() === false) {\n // Not delay since callback cancelled self\n return;\n }\n\n calledRef.current = true;\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n }, buffer);\n } else {\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n trigger();\n }, buffer);\n }\n }\n\n return [trigger, function () {\n calledRef.current = false;\n cancelTrigger();\n }];\n});"]},"metadata":{},"sourceType":"module"}