framer-motion 4.1.14 → 4.1.17

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
@@ -2,7 +2,26 @@
2
2
 
3
3
  Framer Motion adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
- ## [4.1.14] 2021-05-10
5
+ ## [4.1.17] 2021-05-17
6
+
7
+ ### Fixed
8
+
9
+ - Fixing SVG `gradientTransform`.
10
+ - Removing hover event suspension during layout measurements.
11
+
12
+ ## [4.1.16] 2021-05-12
13
+
14
+ ### Fixed
15
+
16
+ - Use with changing external refs.
17
+
18
+ ## [4.1.15] 2021-05-11
19
+
20
+ ### Fixed
21
+
22
+ - Correctly firing `onAnimationComplete` when a spring animation defined by `bounce` and no `duration` is completed.
23
+
24
+ ## [4.1.14] 2021-05-11
6
25
 
7
26
  ### Fixed
8
27
 
@@ -2,16 +2,12 @@ import { isMouseEvent } from './utils/event-type.js';
2
2
  import { AnimationType } from '../render/utils/types.js';
3
3
  import { usePointerEvent } from '../events/use-pointer-event.js';
4
4
  import { isDragActive } from './drag/utils/lock.js';
5
- import { layoutState } from '../render/dom/utils/batch-layout.js';
6
5
 
7
6
  function createHoverEvent(visualElement, isActive, callback) {
8
7
  return function (event, info) {
9
8
  var _a;
10
- if (!isMouseEvent(event) ||
11
- layoutState.isMeasuringLayout ||
12
- isDragActive()) {
9
+ if (!isMouseEvent(event) || isDragActive())
13
10
  return;
14
- }
15
11
  callback === null || callback === void 0 ? void 0 : callback(event, info);
16
12
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, isActive);
17
13
  };
@@ -22,7 +22,13 @@ function useMotionRef(visualState, visualElement, externalRef) {
22
22
  externalRef.current = instance;
23
23
  }
24
24
  }
25
- }, [visualElement, externalRef]);
25
+ },
26
+ /**
27
+ * Only pass a new ref callback to React if we've received a visual element
28
+ * factory. Otherwise we'll be mounting/remounting every time externalRef
29
+ * or other dependencies change.
30
+ */
31
+ [visualElement]);
26
32
  }
27
33
 
28
34
  export { useMotionRef };
@@ -1,9 +1,4 @@
1
- import sync from 'framesync';
2
-
3
1
  var unresolvedJobs = new Set();
4
- var layoutState = {
5
- isMeasuringLayout: false,
6
- };
7
2
  function pushJob(stack, job, pointer) {
8
3
  if (!stack[pointer])
9
4
  stack[pointer] = [];
@@ -32,24 +27,6 @@ function flushLayout() {
32
27
  pointer = 0;
33
28
  });
34
29
  unresolvedJobs.clear();
35
- /**
36
- * Mark that we're currently measuring layouts. This allows us to, for instance, ignore
37
- * hover events that might be triggered as a result of resetting transforms.
38
- *
39
- * The postRender/setTimeout combo seems like an odd bit of scheduling but what it's saying
40
- * is *after* the next render, wait 10ms before re-enabling hover events. Waiting until the
41
- * next frame completely will result in missed, valid hover events. But events seem to
42
- * be fired async from their actual action, so setting this to false too soon can still
43
- * trigger events from layout measurements.
44
- *
45
- * Note: If we figure out a way of measuring layout while transforms remain applied, this can be removed.
46
- * I have attempted unregistering event listeners and setting CSS to pointer-events: none
47
- * but neither seem to work as expected.
48
- */
49
- layoutState.isMeasuringLayout = true;
50
- sync.postRender(function () {
51
- setTimeout(function () { return (layoutState.isMeasuringLayout = false); }, 10);
52
- });
53
30
  /**
54
31
  * Execute jobs
55
32
  */
@@ -61,4 +38,4 @@ function flushLayout() {
61
38
  }
62
39
  var executeJob = function (job) { return job(); };
63
40
 
64
- export { batchLayout, flushLayout, layoutState };
41
+ export { batchLayout, flushLayout };
@@ -20,6 +20,7 @@ var camelCaseAttributes = new Set([
20
20
  "stdDeviation",
21
21
  "tableValues",
22
22
  "viewBox",
23
+ "gradientTransform",
23
24
  ]);
24
25
 
25
26
  export { camelCaseAttributes };
@@ -6,8 +6,8 @@ var tslib = require('tslib');
6
6
  var React = require('react');
7
7
  var heyListen = require('hey-listen');
8
8
  var styleValueTypes = require('style-value-types');
9
- var sync = require('framesync');
10
9
  var popmotion = require('popmotion');
10
+ var sync = require('framesync');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -300,7 +300,13 @@ function useMotionRef(visualState, visualElement, externalRef) {
300
300
  externalRef.current = instance;
301
301
  }
302
302
  }
303
- }, [visualElement, externalRef]);
303
+ },
304
+ /**
305
+ * Only pass a new ref callback to React if we've received a visual element
306
+ * factory. Otherwise we'll be mounting/remounting every time externalRef
307
+ * or other dependencies change.
308
+ */
309
+ [visualElement]);
304
310
  }
305
311
 
306
312
  /**
@@ -1176,6 +1182,7 @@ var camelCaseAttributes = new Set([
1176
1182
  "stdDeviation",
1177
1183
  "tableValues",
1178
1184
  "viewBox",
1185
+ "gradientTransform",
1179
1186
  ]);
1180
1187
 
1181
1188
  function renderSVG(element, renderState) {
@@ -1568,75 +1575,11 @@ function isDragActive() {
1568
1575
  return false;
1569
1576
  }
1570
1577
 
1571
- var unresolvedJobs = new Set();
1572
- var layoutState = {
1573
- isMeasuringLayout: false,
1574
- };
1575
- function pushJob(stack, job, pointer) {
1576
- if (!stack[pointer])
1577
- stack[pointer] = [];
1578
- stack[pointer].push(job);
1579
- }
1580
- function batchLayout(callback) {
1581
- unresolvedJobs.add(callback);
1582
- return function () { return unresolvedJobs.delete(callback); };
1583
- }
1584
- function flushLayout() {
1585
- if (!unresolvedJobs.size)
1586
- return;
1587
- var pointer = 0;
1588
- var reads = [[]];
1589
- var writes = [];
1590
- var setRead = function (job) { return pushJob(reads, job, pointer); };
1591
- var setWrite = function (job) {
1592
- pushJob(writes, job, pointer);
1593
- pointer++;
1594
- };
1595
- /**
1596
- * Resolve jobs into their array stacks
1597
- */
1598
- unresolvedJobs.forEach(function (callback) {
1599
- callback(setRead, setWrite);
1600
- pointer = 0;
1601
- });
1602
- unresolvedJobs.clear();
1603
- /**
1604
- * Mark that we're currently measuring layouts. This allows us to, for instance, ignore
1605
- * hover events that might be triggered as a result of resetting transforms.
1606
- *
1607
- * The postRender/setTimeout combo seems like an odd bit of scheduling but what it's saying
1608
- * is *after* the next render, wait 10ms before re-enabling hover events. Waiting until the
1609
- * next frame completely will result in missed, valid hover events. But events seem to
1610
- * be fired async from their actual action, so setting this to false too soon can still
1611
- * trigger events from layout measurements.
1612
- *
1613
- * Note: If we figure out a way of measuring layout while transforms remain applied, this can be removed.
1614
- * I have attempted unregistering event listeners and setting CSS to pointer-events: none
1615
- * but neither seem to work as expected.
1616
- */
1617
- layoutState.isMeasuringLayout = true;
1618
- sync__default['default'].postRender(function () {
1619
- setTimeout(function () { return (layoutState.isMeasuringLayout = false); }, 10);
1620
- });
1621
- /**
1622
- * Execute jobs
1623
- */
1624
- var numStacks = writes.length;
1625
- for (var i = 0; i <= numStacks; i++) {
1626
- reads[i] && reads[i].forEach(executeJob);
1627
- writes[i] && writes[i].forEach(executeJob);
1628
- }
1629
- }
1630
- var executeJob = function (job) { return job(); };
1631
-
1632
1578
  function createHoverEvent(visualElement, isActive, callback) {
1633
1579
  return function (event, info) {
1634
1580
  var _a;
1635
- if (!isMouseEvent(event) ||
1636
- layoutState.isMeasuringLayout ||
1637
- isDragActive()) {
1581
+ if (!isMouseEvent(event) || isDragActive())
1638
1582
  return;
1639
- }
1640
1583
  callback === null || callback === void 0 ? void 0 : callback(event, info);
1641
1584
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, isActive);
1642
1585
  };
@@ -3786,6 +3729,46 @@ function convertToRelativeProjection(visualElement, isLayoutDrag) {
3786
3729
  return true;
3787
3730
  }
3788
3731
 
3732
+ var unresolvedJobs = new Set();
3733
+ function pushJob(stack, job, pointer) {
3734
+ if (!stack[pointer])
3735
+ stack[pointer] = [];
3736
+ stack[pointer].push(job);
3737
+ }
3738
+ function batchLayout(callback) {
3739
+ unresolvedJobs.add(callback);
3740
+ return function () { return unresolvedJobs.delete(callback); };
3741
+ }
3742
+ function flushLayout() {
3743
+ if (!unresolvedJobs.size)
3744
+ return;
3745
+ var pointer = 0;
3746
+ var reads = [[]];
3747
+ var writes = [];
3748
+ var setRead = function (job) { return pushJob(reads, job, pointer); };
3749
+ var setWrite = function (job) {
3750
+ pushJob(writes, job, pointer);
3751
+ pointer++;
3752
+ };
3753
+ /**
3754
+ * Resolve jobs into their array stacks
3755
+ */
3756
+ unresolvedJobs.forEach(function (callback) {
3757
+ callback(setRead, setWrite);
3758
+ pointer = 0;
3759
+ });
3760
+ unresolvedJobs.clear();
3761
+ /**
3762
+ * Execute jobs
3763
+ */
3764
+ var numStacks = writes.length;
3765
+ for (var i = 0; i <= numStacks; i++) {
3766
+ reads[i] && reads[i].forEach(executeJob);
3767
+ writes[i] && writes[i].forEach(executeJob);
3768
+ }
3769
+ }
3770
+ var executeJob = function (job) { return job(); };
3771
+
3789
3772
  var elementDragControls = new WeakMap();
3790
3773
  /**
3791
3774
  *