react-voodoo 2.3.0 → 2.4.1
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/LICENCE.HEAD.MD +6 -19
- package/LICENSE.AGPL-3.0.MD +661 -0
- package/LICENSE.CC-BY-ND.MD +316 -0
- package/dist/react-voodoo.js.LICENSE.txt +6 -21
- package/dist/react-voodoo.js.map +1 -1
- package/package.json +5 -4
- package/readme.md +211 -175
- package/LICENSE.MD +0 -21
package/package.json
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-voodoo",
|
3
|
-
"version": "2.
|
4
|
-
"license": "
|
3
|
+
"version": "2.4.1",
|
4
|
+
"license": "(CC-BY-ND-4.0 OR AGPL-3.0-only)",
|
5
5
|
"main": "./dist/react-voodoo.js",
|
6
6
|
"author": "Nathan Braun <n8tz.js@gmail.com>",
|
7
7
|
"repository": "https://github.com/react-voodoo/react-voodoo",
|
8
|
-
"description": "
|
8
|
+
"description": "Faster, simplier, additive, swipeable & multidimentional animation engine for React",
|
9
9
|
"scripts": {
|
10
10
|
"build": "lpack",
|
11
11
|
"devLib": "lpack :staging -w",
|
12
12
|
"test": "echo ok",
|
13
|
-
"testAuto": "nodemon --watch ./dist/react-voodoo.js --watch ./etc/tests/**/*.js --exec \"npm test\""
|
13
|
+
"testAuto": "nodemon --watch ./dist/react-voodoo.js --watch ./etc/tests/**/*.js --exec \"npm test\"",
|
14
|
+
"setupLayers": "lpack-setup"
|
14
15
|
},
|
15
16
|
"peerDependencies": {
|
16
17
|
"react": "^16.0.0 || ^17.0.1",
|
package/readme.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<h1 align="center">react-voodoo</h1>
|
2
|
-
<p align="center">Fast, SSR
|
2
|
+
<p align="center">Fast, SSR ready, additive & swipeable, tween composition engine for React</p>
|
3
3
|
|
4
4
|
___
|
5
5
|
<p align="center"><img width="192" src ="https://github.com/react-voodoo/react-voodoo/raw/master/doc/assets/logo-v0.png?sanitize=true" /></p>
|
@@ -11,10 +11,13 @@ ___
|
|
11
11
|
<a href="https://travis-ci.org/react-voodoo/react-voodoo">
|
12
12
|
<img src="https://travis-ci.org/react-voodoo/react-voodoo.svg?branch=master" alt="Build Status" /></a>
|
13
13
|
<img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" />
|
14
|
+
<br/>
|
15
|
+
<a href="http://creativecommons.org/licenses/by-nd/4.0">
|
16
|
+
<img src="https://img.shields.io/badge/License-CC%20BY--ND%204.0-lightgrey.svg" alt="License: CC BY-ND 4.0" /></a>
|
17
|
+
<a href="http://www.gnu.org/licenses/agpl-3.0">
|
18
|
+
<img src="https://img.shields.io/badge/License-AGPL%20v3-blue.svg" alt="License: AGPL v3" /></a>
|
14
19
|
</p>
|
15
20
|
|
16
|
-
|
17
|
-
|
18
21
|
## Why another animation engine ?
|
19
22
|
|
20
23
|
To have some advanced functionalities :
|
@@ -31,12 +34,13 @@ To have some advanced functionalities :
|
|
31
34
|
- Automatically deal with multiple units using css "calc( ... )"
|
32
35
|
- etc...
|
33
36
|
|
34
|
-
##
|
35
|
-
<p align="center"><img src ="https://github.com/react-voodoo/react-voodoo/raw/master/doc/assets/demo.gif?sanitize=true" /></p>
|
37
|
+
## Basic documentation [here](doc/readme.md)
|
36
38
|
|
37
|
-
##
|
39
|
+
## Live demo & codesandbox [here](https://react-voodoo.github.io/react-voodoo-samples/)
|
38
40
|
|
39
|
-
|
41
|
+
<p align="center"><img src ="https://github.com/react-voodoo/react-voodoo/raw/master/doc/assets/demo.gif?sanitize=true" /></p>
|
42
|
+
|
43
|
+
## Samples sources [here](https://github.com/react-voodoo/react-voodoo-samples)
|
40
44
|
|
41
45
|
## Note
|
42
46
|
|
@@ -55,186 +59,218 @@ react-voodoo still miss some interpolator ( like background or borders ).<br/>
|
|
55
59
|
"all in one" example :
|
56
60
|
|
57
61
|
```jsx harmony
|
58
|
-
|
59
|
-
import
|
60
|
-
import Voodoo from "react-voodoo";
|
62
|
+
import React from "react";
|
63
|
+
import Voodoo from "react-voodoo";
|
61
64
|
import {itemTweenAxis, tweenArrayWithTargets} from "./somewhere";
|
62
65
|
|
63
66
|
const styleSample = {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
67
|
+
/**
|
68
|
+
* Voodoo.Node style property and the tween descriptors use classic CSS-in-JS declaration
|
69
|
+
* exept we can specify values using the "box" unit which is a [0-1] ratio of the parent ViewBox height / width
|
70
|
+
*/
|
71
|
+
|
72
|
+
height: "50%",
|
73
|
+
|
74
|
+
// the tweener deal with multiple units
|
75
|
+
// it will use css calc fn to add them if there's more than 1 unit used
|
76
|
+
width: ["50%", "10vw", "-50px", ".2box"],
|
77
|
+
|
78
|
+
// transform can use multiple "layers"
|
79
|
+
transform: [
|
80
|
+
{
|
81
|
+
// use rotate(X|Y|Z) & translate(X|Y|Z)
|
82
|
+
rotateX: "25deg"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
translateZ: "-.2box"
|
86
|
+
}
|
87
|
+
],
|
88
|
+
|
89
|
+
filter:
|
90
|
+
{
|
91
|
+
blur: "5px"
|
92
|
+
}
|
85
93
|
};
|
86
|
-
const axisSample
|
94
|
+
const axisSample = [// Examples of tween descriptors
|
95
|
+
{
|
96
|
+
target : "someTweenRefId", // target Voodoo.Node id ( optional if used as parameter on a Voodoo.Node as it will target it )
|
97
|
+
from : 0, // tween start position
|
98
|
+
duration: 100, // tween duration
|
99
|
+
easeFn : "easeCircleIn", // function or easing fn id from [d3-ease](https://github.com/d3/d3-ease)
|
100
|
+
|
101
|
+
apply: {// relative css values to be applied
|
102
|
+
// Same syntax as the styles
|
103
|
+
transform: [{}, {
|
104
|
+
translateZ: "-.2box"
|
105
|
+
}]
|
106
|
+
}
|
107
|
+
},
|
87
108
|
{
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
// triggered when axis has scrolled in the Event period
|
105
|
-
// delta : [-1,1] is the update inside the Event period
|
106
|
-
entering:(delta)=>false,
|
107
|
-
|
108
|
-
// triggered when axis has scrolled in the Event period
|
109
|
-
// newPos, precPos : [0,1] position inside the Event period
|
110
|
-
// delta : [-1,1] is the update inside the Event period
|
111
|
-
moving:(newPos, precPos, delta)=>false,
|
112
|
-
|
113
|
-
// triggered when axis has scrolled out the Event period
|
114
|
-
// delta : [-1,1] is the update inside the Event period
|
115
|
-
leaving:(delta)=>false
|
116
|
-
}
|
109
|
+
from : 40,
|
110
|
+
duration: 20,
|
111
|
+
|
112
|
+
// triggered when axis has scrolled in the Event period
|
113
|
+
// delta : a float value between [-1,1] is the update inside the Event period
|
114
|
+
entering: ( delta ) => false,
|
115
|
+
|
116
|
+
// triggered when axis has scrolled in the Event period
|
117
|
+
// newPos, precPos : float values between [0,1] position inside the Event period
|
118
|
+
// delta : a float value between [-1,1] is the update inside the Event period
|
119
|
+
moving: ( newPos, precPos, delta ) => false,
|
120
|
+
|
121
|
+
// triggered when axis has scrolled out the Event period
|
122
|
+
// delta : a float value between [-1,1] is the update inside the Event period
|
123
|
+
leaving: ( delta ) => false
|
124
|
+
}
|
117
125
|
];
|
118
126
|
|
119
127
|
const Sample = ( {} ) => {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Voodoo tweener instanciation
|
131
|
+
*/
|
132
|
+
// Classic minimal method
|
133
|
+
const [tweener, ViewBox] = Voodoo.hook();
|
134
|
+
// get the first tweener in parents
|
135
|
+
const [parentTweener] = Voodoo.hook(true);
|
136
|
+
// Create a tweener with options
|
137
|
+
const [twenerWithNameAndOptions, ViewBox2] = Voodoo.hook(
|
138
|
+
{
|
139
|
+
// Give an id to this tweener so we can access it's axes in the childs components
|
140
|
+
name: "root",
|
141
|
+
// max click tm in ms before a click become a drag
|
142
|
+
maxClickTm: 200,
|
143
|
+
// max drag offset in px before a click become a drag
|
144
|
+
maxClickOffset: 100,
|
145
|
+
// lock to only 1 drag direction
|
146
|
+
dragDirectionLock: false,
|
147
|
+
// allow dragging with mouse
|
148
|
+
enableMouseDrag: false
|
149
|
+
}
|
150
|
+
);
|
151
|
+
// get a named parent tweener
|
152
|
+
const [nammedParentTweener] = Voodoo.hook("root")
|
153
|
+
|
154
|
+
/**
|
155
|
+
* once first render done, axes expose the following values & functions :
|
156
|
+
*/
|
157
|
+
// Theirs actual position in :
|
158
|
+
// tweener.axes.(axisId).scrollPos
|
159
|
+
|
160
|
+
// The "scrollTo" function allowing to manually move the axes positions :
|
161
|
+
// tweener.axes.(axisId).scrollTo(targetPos, duration, easeFn)
|
162
|
+
// tweener.scrollTo(targetPos, duration, axisId, easeFn)
|
163
|
+
|
164
|
+
// They can also be watched using the "watchAxis" function;
|
165
|
+
// When called, the returned function will disable the listener if executed :
|
166
|
+
React.useEffect(
|
167
|
+
e => tweener?.watchAxis("scrollY", ( pos ) => doSomething()),
|
168
|
+
[tweener]
|
169
|
+
)
|
170
|
+
|
171
|
+
return <ViewBox className={"container"}>
|
172
|
+
<Voodoo.Axis
|
173
|
+
|
174
|
+
id={"scrollY"} // Tween axis Id
|
175
|
+
defaultPosition={100} // optional initial position ( default : 0 )
|
176
|
+
|
177
|
+
// optional Array of tween descriptors with theirs Voodoo.Node target ids ( see axisSample )
|
178
|
+
items={tweenArrayWithTargets}
|
179
|
+
|
180
|
+
// optional size of the scrollable window for drag synchronisation
|
181
|
+
scrollableWindow={200}
|
182
|
+
|
183
|
+
// optional length of this scrollable axis (default to last tween desciptor position+duration)
|
184
|
+
size={1000}
|
185
|
+
|
186
|
+
// optional bounds ( inertia will target them if target pos is out )
|
187
|
+
bounds={{ min: 100, max: 900 }}
|
188
|
+
|
189
|
+
// optional inertia cfg ( false to disable it )
|
190
|
+
inertia={
|
191
|
+
{
|
192
|
+
// called when inertia is updated
|
193
|
+
// should return instantaneous move to do if wanted
|
194
|
+
shouldLoop: ( currentPos ) => (currentPos > 500 ? -500 : null),
|
195
|
+
|
196
|
+
// called when inertia know where it will end ( when the user stop dragging )
|
197
|
+
willEnd: ( targetPos, targetDelta, duration ) => {
|
198
|
+
},
|
199
|
+
|
200
|
+
// called when inertia know where it will snap ( when the user stop dragging )
|
201
|
+
willSnap: ( currentSnapIndex, targetWayPointObj ) => {
|
202
|
+
},
|
203
|
+
|
204
|
+
// called when inertia end
|
205
|
+
onStop: ( pos, targetWayPointObj ) => {
|
206
|
+
},
|
207
|
+
|
208
|
+
// called when inertia end on a snap
|
209
|
+
onSnap: ( snapIndex, targetWayPointObj ) => {
|
210
|
+
},
|
211
|
+
|
212
|
+
// list of waypoints object ( only support auto snap 50/50 for now )
|
213
|
+
wayPoints: [{ at: 100 }, { at: 200 }]
|
214
|
+
}
|
215
|
+
}
|
216
|
+
/>
|
217
|
+
|
218
|
+
<Voodoo.Node
|
219
|
+
id={"testItem"} // optional id
|
220
|
+
|
221
|
+
style={styleSample}// optional styles applied before any style coming from axes : css syntax + voodoo tweener units & transform management
|
222
|
+
|
223
|
+
axes={{ scrollY: axisSample }} // optional Array of tween by axis Id with no target node id required ( it will be ignored )
|
224
|
+
|
225
|
+
onClick={// all unknow props are passed to the child node
|
226
|
+
( e ) => {
|
227
|
+
// start playing an anim ( prefer scrolling Axes )
|
228
|
+
tweener.pushAnim(
|
229
|
+
// make all tween target "testItem"
|
230
|
+
Voodoo.tools.target(pushIn, "testItem")
|
231
|
+
).then(
|
232
|
+
( tweenAxis ) => {
|
233
|
+
// doSomething next
|
234
|
+
}
|
235
|
+
);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
>
|
239
|
+
<Voodoo.Draggable
|
240
|
+
// make drag y move the scrollAnAxis axis
|
241
|
+
// xAxis={ "scrollAnAxis" }
|
242
|
+
|
243
|
+
// scale / inverse dispatched delta
|
244
|
+
// xHook={(delta)=>modify(delta)}
|
245
|
+
|
246
|
+
// React ref to the box, default to the parent ViewBox
|
247
|
+
// scale is as follow : (delta / ((xBoxRef||ViewBox).offsetWidth)) * ( axis.scrollableWindow || axis.duration )
|
248
|
+
// xBoxRef={ref}
|
249
|
+
|
250
|
+
yAxis={"scrollY"}// make drag y move the scrollY axis
|
251
|
+
// yHook={(delta)=>modify(delta)}
|
252
|
+
// yBoxRef={ref}
|
253
|
+
|
254
|
+
// mouseDrag={true} // listen for mouse drag ( default to false )
|
255
|
+
// touchDrag={false} // listen for touch drag ( default to true )
|
256
|
+
|
257
|
+
// button={1-3} // limit mouse drag to the specified event.button === ( default to 1; the left btn )
|
258
|
+
|
259
|
+
// * actually Draggable create it's own div node
|
260
|
+
>
|
261
|
+
<div>
|
262
|
+
Some content to tween
|
263
|
+
</div>
|
264
|
+
</Voodoo.Draggable>
|
265
|
+
</Voodoo.Node>
|
266
|
+
</ViewBox>;
|
229
267
|
}
|
230
268
|
```
|
231
269
|
|
232
|
-
##
|
270
|
+
## License ?
|
233
271
|
|
234
|
-
-
|
235
|
-
|
236
|
-
- lot of various simple and/or smart optims / recycling
|
237
|
-
- SVG support
|
272
|
+
Using CC BY-ND, you can use it in commercial apps, but you can't distribute modified versions.<br/>
|
273
|
+
Using AGPL, you can distribute modified versions but theses versions must be AGPL too.
|
238
274
|
|
239
275
|
[](#)
|
240
276
|
[](#)
|
package/LICENSE.MD
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2020 Braun Nathanael
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|