aboutsummaryrefslogtreecommitdiffstats
path: root/.yarn
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-08-23 17:10:46 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-08-23 17:15:05 +0200
commit64f4035ac49b449ed53ba439dcef2fa94cc5844d (patch)
tree858681c4be75643b5906050210387d5e7e56662b /.yarn
parentfeat(web): zoom controls (diff)
downloadrefinery-64f4035ac49b449ed53ba439dcef2fa94cc5844d.tar.gz
refinery-64f4035ac49b449ed53ba439dcef2fa94cc5844d.tar.zst
refinery-64f4035ac49b449ed53ba439dcef2fa94cc5844d.zip
refactor(web): move d3-zoom patch into repo
Instead of referencing an external pull request, move the patch into yarn/.patches and update it to handle pinch-to-zoom.
Diffstat (limited to '.yarn')
-rw-r--r--.yarn/patches/d3-zoom-npm-3.0.0-18f706a421.patch134
1 files changed, 134 insertions, 0 deletions
diff --git a/.yarn/patches/d3-zoom-npm-3.0.0-18f706a421.patch b/.yarn/patches/d3-zoom-npm-3.0.0-18f706a421.patch
new file mode 100644
index 00000000..88d32c72
--- /dev/null
+++ b/.yarn/patches/d3-zoom-npm-3.0.0-18f706a421.patch
@@ -0,0 +1,134 @@
1diff --git a/src/zoom.js b/src/zoom.js
2index d56438823b2882856f156b0915ccbac038d6923e..50936066a3597c46ad65f690e9c8417e9d3375f8 100644
3--- a/src/zoom.js
4+++ b/src/zoom.js
5@@ -14,6 +14,10 @@ function defaultFilter(event) {
6 return (!event.ctrlKey || event.type === 'wheel') && !event.button;
7 }
8
9+function defaultCenter(event) {
10+ return pointer(event, this);
11+}
12+
13 function defaultExtent() {
14 var e = this;
15 if (e instanceof SVGElement) {
16@@ -27,6 +31,10 @@ function defaultExtent() {
17 return [[0, 0], [e.clientWidth, e.clientHeight]];
18 }
19
20+function defaultCentroid(extent) {
21+ return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2];
22+}
23+
24 function defaultTransform() {
25 return this.__zoom || identity;
26 }
27@@ -52,7 +60,9 @@ function defaultConstrain(transform, extent, translateExtent) {
28
29 export default function() {
30 var filter = defaultFilter,
31+ center = defaultCenter,
32 extent = defaultExtent,
33+ centroid = defaultCentroid,
34 constrain = defaultConstrain,
35 wheelDelta = defaultWheelDelta,
36 touchable = defaultTouchable,
37@@ -148,9 +158,6 @@ export default function() {
38 return x === transform.x && y === transform.y ? transform : new Transform(transform.k, x, y);
39 }
40
41- function centroid(extent) {
42- return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2];
43- }
44
45 function schedule(transition, transform, point, event) {
46 transition
47@@ -243,6 +250,7 @@ export default function() {
48 if (g.wheel) {
49 if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
50 g.mouse[1] = t.invert(g.mouse[0] = p);
51+ g.mouse[2] = center.apply(this, arguments);
52 }
53 clearTimeout(g.wheel);
54 }
55@@ -252,14 +260,14 @@ export default function() {
56
57 // Otherwise, capture the mouse point and location at the start.
58 else {
59- g.mouse = [p, t.invert(p)];
60+ g.mouse = [p, t.invert(p), center.apply(this, arguments)];
61 interrupt(this);
62 g.start();
63 }
64
65 noevent(event);
66 g.wheel = setTimeout(wheelidled, wheelDelay);
67- g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent, translateExtent));
68+ g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[2], t.invert(g.mouse[2])), g.extent, translateExtent));
69
70 function wheelidled() {
71 g.wheel = null;
72@@ -278,7 +286,7 @@ export default function() {
73
74 dragDisable(event.view);
75 nopropagation(event);
76- g.mouse = [p, this.__zoom.invert(p)];
77+ g.prev = p;
78 interrupt(this);
79 g.start();
80
81@@ -288,8 +296,10 @@ export default function() {
82 var dx = event.clientX - x0, dy = event.clientY - y0;
83 g.moved = dx * dx + dy * dy > clickDistance2;
84 }
85+ var p = pointer(event, currentTarget);
86 g.event(event)
87- .zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = pointer(event, currentTarget), g.mouse[1]), g.extent, translateExtent));
88+ .zoom("mouse", constrain(translate(g.that.__zoom, p, g.that.__zoom.invert(g.prev)), g.extent, translateExtent));
89+ g.prev = p;
90 }
91
92 function mouseupped(event) {
93@@ -303,7 +313,7 @@ export default function() {
94 function dblclicked(event, ...args) {
95 if (!filter.apply(this, arguments)) return;
96 var t0 = this.__zoom,
97- p0 = pointer(event.changedTouches ? event.changedTouches[0] : event, this),
98+ p0 = center.call(this, event.changedTouches ? event.changedTouches[0] : event),
99 p1 = t0.invert(p0),
100 k1 = t0.k * (event.shiftKey ? 0.5 : 2),
101 t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, args), translateExtent);
102@@ -322,7 +332,7 @@ export default function() {
103
104 nopropagation(event);
105 for (i = 0; i < n; ++i) {
106- t = touches[i], p = pointer(t, this);
107+ t = touches[i], p = center.call(this, t);
108 p = [p, this.__zoom.invert(p), t.identifier];
109 if (!g.touch0) g.touch0 = p, started = true, g.taps = 1 + !!touchstarting;
110 else if (!g.touch1 && g.touch0[2] !== p[2]) g.touch1 = p, g.taps = 0;
111@@ -345,7 +355,7 @@ export default function() {
112
113 noevent(event);
114 for (i = 0; i < n; ++i) {
115- t = touches[i], p = pointer(t, this);
116+ t = touches[i], p = center.call(this, t);
117 if (g.touch0 && g.touch0[2] === t.identifier) g.touch0[0] = p;
118 else if (g.touch1 && g.touch1[2] === t.identifier) g.touch1[0] = p;
119 }
120@@ -406,6 +416,14 @@ export default function() {
121 return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(!!_), zoom) : touchable;
122 };
123
124+ zoom.center = function(_) {
125+ return arguments.length ? (center = typeof _ === "function" ? _ : constant([+_[0], +_[1]]), zoom) : center;
126+ };
127+
128+ zoom.centroid = function(_) {
129+ return arguments.length ? (centroid = typeof _ === "function" ? _ : constant([+_[0], +_[1]]), zoom) : centroid;
130+ };
131+
132 zoom.extent = function(_) {
133 return arguments.length ? (extent = typeof _ === "function" ? _ : constant([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), zoom) : extent;
134 };