framer-motion 11.3.2 → 11.3.4

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.
@@ -91,38 +91,13 @@
91
91
  useManualTiming: false,
92
92
  };
93
93
 
94
- class Queue {
95
- constructor() {
96
- this.order = [];
97
- this.scheduled = new Set();
98
- }
99
- add(process) {
100
- if (!this.scheduled.has(process)) {
101
- this.scheduled.add(process);
102
- this.order.push(process);
103
- return true;
104
- }
105
- }
106
- remove(process) {
107
- const index = this.order.indexOf(process);
108
- if (index !== -1) {
109
- this.order.splice(index, 1);
110
- this.scheduled.delete(process);
111
- }
112
- }
113
- clear() {
114
- this.order.length = 0;
115
- this.scheduled.clear();
116
- }
117
- }
118
94
  function createRenderStep(runNextFrame) {
119
95
  /**
120
96
  * We create and reuse two queues, one to queue jobs for the current frame
121
97
  * and one for the next. We reuse to avoid triggering GC after x frames.
122
98
  */
123
- let thisFrame = new Queue();
124
- let nextFrame = new Queue();
125
- let numToRun = 0;
99
+ let thisFrame = new Set();
100
+ let nextFrame = new Set();
126
101
  /**
127
102
  * Track whether we're currently processing jobs in this step. This way
128
103
  * we can decide whether to schedule new jobs for this frame or next.
@@ -133,6 +108,18 @@
133
108
  * A set of processes which were marked keepAlive when scheduled.
134
109
  */
135
110
  const toKeepAlive = new WeakSet();
111
+ let latestFrameData = {
112
+ delta: 0,
113
+ timestamp: 0,
114
+ isProcessing: false,
115
+ };
116
+ function triggerCallback(callback) {
117
+ if (toKeepAlive.has(callback)) {
118
+ step.schedule(callback);
119
+ runNextFrame();
120
+ }
121
+ callback(latestFrameData);
122
+ }
136
123
  const step = {
137
124
  /**
138
125
  * Schedule a process to run on the next frame.
@@ -142,23 +129,22 @@
142
129
  const queue = addToCurrentFrame ? thisFrame : nextFrame;
143
130
  if (keepAlive)
144
131
  toKeepAlive.add(callback);
145
- if (queue.add(callback) && addToCurrentFrame && isProcessing) {
146
- // If we're adding it to the currently running queue, update its measured size
147
- numToRun = thisFrame.order.length;
148
- }
132
+ if (!queue.has(callback))
133
+ queue.add(callback);
149
134
  return callback;
150
135
  },
151
136
  /**
152
137
  * Cancel the provided callback from running on the next frame.
153
138
  */
154
139
  cancel: (callback) => {
155
- nextFrame.remove(callback);
140
+ nextFrame.delete(callback);
156
141
  toKeepAlive.delete(callback);
157
142
  },
158
143
  /**
159
144
  * Execute all schedule callbacks.
160
145
  */
161
146
  process: (frameData) => {
147
+ latestFrameData = frameData;
162
148
  /**
163
149
  * If we're already processing we've probably been triggered by a flushSync
164
150
  * inside an existing process. Instead of executing, mark flushNextFrame
@@ -173,17 +159,7 @@
173
159
  // Clear the next frame queue
174
160
  nextFrame.clear();
175
161
  // Execute this frame
176
- numToRun = thisFrame.order.length;
177
- if (numToRun) {
178
- for (let i = 0; i < numToRun; i++) {
179
- const callback = thisFrame.order[i];
180
- if (toKeepAlive.has(callback)) {
181
- step.schedule(callback);
182
- runNextFrame();
183
- }
184
- callback(frameData);
185
- }
186
- }
162
+ thisFrame.forEach(triggerCallback);
187
163
  isProcessing = false;
188
164
  if (flushNextFrame) {
189
165
  flushNextFrame = false;
@@ -4869,7 +4845,7 @@
4869
4845
  * This will be replaced by the build step with the latest version number.
4870
4846
  * When MotionValues are provided to motion components, warn if versions are mixed.
4871
4847
  */
4872
- this.version = "11.3.2";
4848
+ this.version = "11.3.4";
4873
4849
  /**
4874
4850
  * Tracks whether this value can output a velocity. Currently this is only true
4875
4851
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -6236,10 +6212,10 @@
6236
6212
  * TODO: Prefer to remove this, but currently we have motion components with
6237
6213
  * display: contents in Framer.
6238
6214
  */
6239
- const instance = node.instance;
6240
- if (instance &&
6241
- instance.style &&
6242
- instance.style.display === "contents") {
6215
+ const { visualElement } = node.options;
6216
+ if (visualElement &&
6217
+ visualElement.props.style &&
6218
+ visualElement.props.style.display === "contents") {
6243
6219
  continue;
6244
6220
  }
6245
6221
  if (isSharedTransition &&
@@ -7317,7 +7293,7 @@
7317
7293
  * and warn against mismatches.
7318
7294
  */
7319
7295
  {
7320
- warnOnce(nextValue.version === "11.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.2 may not work as expected.`);
7296
+ warnOnce(nextValue.version === "11.3.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.4 may not work as expected.`);
7321
7297
  }
7322
7298
  }
7323
7299
  else if (isMotionValue(prevValue)) {