@next-core/brick-utils 2.35.3 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.36.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.35.3...@next-core/brick-utils@2.36.0) (2022-03-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * new util function: debounceByAnimationFrame ([d47d032](https://github.com/easyops-cn/next-core/commit/d47d032dea4f9a55e8b642b0d2af926e808c716f))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.35.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.35.2...@next-core/brick-utils@2.35.3) (2022-03-15)
7
18
 
8
19
  **Note:** Version bump only for package @next-core/brick-utils
@@ -22143,6 +22143,29 @@
22143
22143
  return false;
22144
22144
  }
22145
22145
 
22146
+ // The debounce function receives our function as a parameter
22147
+ function debounceByAnimationFrame(fn) {
22148
+ // This holds the requestAnimationFrame reference, so we can cancel it if we wish
22149
+ var frame; // The debounce function returns a new function that can receive a variable number of arguments
22150
+
22151
+ return function () {
22152
+ for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
22153
+ params[_key] = arguments[_key];
22154
+ }
22155
+
22156
+ // If the frame variable has been defined, clear it now, and queue for next frame
22157
+ if (frame) {
22158
+ cancelAnimationFrame(frame);
22159
+ } // Queue our function call for the next frame
22160
+
22161
+
22162
+ frame = requestAnimationFrame(() => {
22163
+ // Call our function and pass any params we received
22164
+ fn(...params);
22165
+ });
22166
+ };
22167
+ }
22168
+
22146
22169
  Object.defineProperty(exports, 'pipes', {
22147
22170
  enumerable: true,
22148
22171
  get: function () { return pipes.pipes; }
@@ -22156,6 +22179,7 @@
22156
22179
  exports.convertValueByPrecision = convertValueByPrecision;
22157
22180
  exports.cook = cook;
22158
22181
  exports.createProviderClass = createProviderClass;
22182
+ exports.debounceByAnimationFrame = debounceByAnimationFrame;
22159
22183
  exports.deepFreeze = deepFreeze;
22160
22184
  exports.formatValue = formatValue;
22161
22185
  exports.getDependencyMapOfContext = getDependencyMapOfContext;