rytm-webflow 2.0.5 → 2.0.7
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/README.md +61 -7
- package/package.json +1 -1
- package/scripts/aswap/Controller.js +6 -0
- package/scripts/aswap/View.js +10 -0
- package/scripts/index.js +3 -1
- package/scripts/lib/dataTweenParser.js +1 -1
- package/scripts/showup/ShowUp.js +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# rytm-webflow
|
|
2
2
|
Rytm webflow pack is used to make websites rendered on the server (using a PHP or other back-end) more dynamic.
|
|
3
|
-
A static website can be transformed into something we call a *pseudo single page application* (SPA). The pack includes
|
|
4
|
-
|
|
3
|
+
A static website can be transformed into something we call a *pseudo single page application* (SPA). The pack includes [ASwap](#aswap) - a framework under developement by Rytm.Digital since 2016 which uses *AJAX* / *fetch* to first load and then *swap* the page's content in user's browser.
|
|
4
|
+
This package comes with a handy [WebflowView](#webflowview).
|
|
5
|
+
Another future rytm-webflow includes is [ShowUp](#showup) - a ScrollMagic.js wrapper which can be integrated with ASwap.
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
**Install using NPM:**
|
|
@@ -14,7 +15,7 @@ $ npm install rytm-webflow --save
|
|
|
14
15
|
- scrollmagic
|
|
15
16
|
- scrollmagic-plugin-gsap
|
|
16
17
|
|
|
17
|
-
## ASwap
|
|
18
|
+
## <a name="aswap">ASwap</a>
|
|
18
19
|
### Basic usage example
|
|
19
20
|
In your HTML for each request you neeed a wrapper (default wrapper selector: ```#stage```)
|
|
20
21
|
Inside a wrapper you can have multiple view instances. Each view uses a name defined in ```data-as-view``` and an unique id defined in ```data-as-id```
|
|
@@ -217,9 +218,62 @@ RytmWebflow.aswap.init(params, {
|
|
|
217
218
|
},
|
|
218
219
|
})
|
|
219
220
|
```
|
|
221
|
+
## <a name="webflowview">WebflowView</a> ##
|
|
222
|
+
WebflowView is an universal ASwap View which can be used with the **Webflow syntax** - a minified way to describe an animation, it's duration (time), easing, delay or the trigger. Eg. `y:100,o:0` will animate an element from: `y:100px` and `opacity: 0` to it's current state. Go to [Webflow syntax](#webflowsyntax) for more.
|
|
223
|
+
### Basic usage example
|
|
224
|
+
Define the route:
|
|
225
|
+
```js
|
|
226
|
+
import RytmWebflow from 'rytm-webflow'
|
|
227
|
+
|
|
228
|
+
RytmWebflow.aswap.init({
|
|
229
|
+
routes: {
|
|
230
|
+
"webflow" : {
|
|
231
|
+
controller: RytmWebflow.Controller,
|
|
232
|
+
view: RytmWebflow.WebflowView
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
Add data attributes to the cointainer element:
|
|
238
|
+
```html
|
|
239
|
+
<div id="stage">
|
|
240
|
+
<div data-as-view="webflow" data-as-id="uid">
|
|
241
|
+
...
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
```
|
|
245
|
+
Animate any element within the *WebflowView* container using the **Webflow syntax** inside the `webview` attributes (initial, show, hide):
|
|
246
|
+
```html
|
|
247
|
+
<div data-webview-initial="o:0" data-webview-show="o:1,t:.5" data-webview-hide="o:0,t:.4">
|
|
248
|
+
...
|
|
249
|
+
</div>
|
|
250
|
+
```
|
|
251
|
+
or (more complex example):
|
|
252
|
+
```html
|
|
253
|
+
<div data-webview-initial="x:-10,y:50" data-webview-show="x:0,y:0,t:.5,d:.15,e:Power2.easeOut" data-webview-hide="x:10,y:-25,t:.4,d:.2,e:Power2.easeIn">
|
|
254
|
+
...
|
|
255
|
+
</div>
|
|
256
|
+
```
|
|
257
|
+
### Stagger - animate any list of items
|
|
258
|
+
Animate elements nested under the WebflowView container when scrolled into viewport by using `stagger` data attributes (initial, show, hide) and the `data-webset` attribute:
|
|
259
|
+
```html
|
|
260
|
+
<ul data-stagger-initial="o:0" data-stagger-show="o:1,t:.5,stagger:.1" data-stagger-hide="o:0,t:.4,stagger:.1" data-webset="selector:li">
|
|
261
|
+
<li>...</li>
|
|
262
|
+
<li>...</li>
|
|
263
|
+
</ul>
|
|
264
|
+
```
|
|
265
|
+
### Scrollmagic - animate elements when scrolled into viewport
|
|
266
|
+
Scroll-triggered-animations of any element inside the *WebflowView* container. Use the `webscroll` data attributes (initial, show, hide):
|
|
267
|
+
```html
|
|
268
|
+
<div data-webscroll-initial="y:100" data-webscroll-show="y:0,t:.5" data-webscroll-hide="o:0,t:.4">
|
|
269
|
+
...
|
|
270
|
+
</div>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
|
|
220
274
|
|
|
221
|
-
## ShowUp ##
|
|
222
|
-
ShowUp makes creating gsap scroll-triggered-animations much faster. It can be used to show content while user scrolls down the page. It can also be used for parallax like animations. ShowUp comes with the **Webflow syntax
|
|
275
|
+
## <a name="showup">ShowUp</a> ##
|
|
276
|
+
ShowUp makes creating gsap scroll-triggered-animations much faster. It can be used to show content while user scrolls down the page. It can also be used for parallax like animations. ShowUp comes with the **Webflow syntax**. Go to [Webflow syntax](#webflowsyntax) for more.
|
|
223
277
|
### Webflow usage example
|
|
224
278
|
To enable ShowUp call the init method in your JS:
|
|
225
279
|
```js
|
|
@@ -315,11 +369,11 @@ When moving elements in the Y axis you can use the `parent` trigger hook:
|
|
|
315
369
|
<div data-webpara="y:-100" data-webset="duration:100%,trigger:parent"></div>
|
|
316
370
|
</div>
|
|
317
371
|
```
|
|
318
|
-
### Webflow syntax ##
|
|
372
|
+
### <a name="webflowsyntax">Webflow syntax</a> ##
|
|
319
373
|
| short code | prameter | example |
|
|
320
374
|
|---|---|---|
|
|
321
375
|
| ```d``` | delay | ```"d:.4"``` |
|
|
322
|
-
| ```e``` | ease | ```"e:Bounce
|
|
376
|
+
| ```e``` | ease | ```"e:Bounce.easeOut"``` |
|
|
323
377
|
| ```h``` | height | ```"h:10"``` |
|
|
324
378
|
| ```o``` | opacity | ```"o:0"``` |
|
|
325
379
|
| ```r``` | rotation | ```"r:180"``` |
|
package/package.json
CHANGED
|
@@ -99,6 +99,9 @@ class Controller {
|
|
|
99
99
|
if (container) {
|
|
100
100
|
container.classList.remove("as-hide")
|
|
101
101
|
}
|
|
102
|
+
if (this.view) {
|
|
103
|
+
this.view.hidden(container);
|
|
104
|
+
}
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/**
|
|
@@ -144,6 +147,9 @@ class Controller {
|
|
|
144
147
|
if (container) {
|
|
145
148
|
container.classList.remove("as-show")
|
|
146
149
|
}
|
|
150
|
+
if (this.view) {
|
|
151
|
+
this.view.shown(container);
|
|
152
|
+
}
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
|
package/scripts/aswap/View.js
CHANGED
|
@@ -19,6 +19,11 @@ class View {
|
|
|
19
19
|
this.active = false;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
+
* view is hidden
|
|
23
|
+
**/
|
|
24
|
+
hidden(container) {
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
22
27
|
* prepare (before show)
|
|
23
28
|
**/
|
|
24
29
|
prepare(container) {
|
|
@@ -29,6 +34,11 @@ class View {
|
|
|
29
34
|
show(container) {
|
|
30
35
|
this.active = true;
|
|
31
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* view is shown
|
|
39
|
+
**/
|
|
40
|
+
shown(container) {
|
|
41
|
+
}
|
|
32
42
|
/**
|
|
33
43
|
* images loading start
|
|
34
44
|
* fired only if ControllerImgLoad is used
|
package/scripts/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import bootsrap5 from './bootstrap/v5/Bootstrap5'
|
|
|
7
7
|
// showup
|
|
8
8
|
import scrollController from './showup/ScrollController'
|
|
9
9
|
import showUp from './showup/ShowUp'
|
|
10
|
-
import { getWebflowProps, getParallaxProps } from './lib/dataTweenParser'
|
|
10
|
+
import { getWebflowAnimationProps, getWebflowProps, getParallaxProps, parseProps } from './lib/dataTweenParser'
|
|
11
11
|
import { getScrollMagicSceneProps } from './lib/dataScrollMagicParser'
|
|
12
12
|
|
|
13
13
|
export default {
|
|
@@ -21,7 +21,9 @@ export default {
|
|
|
21
21
|
scrollController,
|
|
22
22
|
showUp,
|
|
23
23
|
// lib
|
|
24
|
+
getWebflowAnimationProps,
|
|
24
25
|
getWebflowProps,
|
|
25
26
|
getParallaxProps,
|
|
27
|
+
parseProps,
|
|
26
28
|
getScrollMagicSceneProps
|
|
27
29
|
}
|
|
@@ -55,7 +55,7 @@ export const getWebflowProps = (dataStr) => {
|
|
|
55
55
|
* @param {string} gstr (eg. y:100,o:0)
|
|
56
56
|
* @return {Object}
|
|
57
57
|
*/
|
|
58
|
-
const getWebflowAnimationProps = (gstr) => {
|
|
58
|
+
export const getWebflowAnimationProps = (gstr) => {
|
|
59
59
|
let propsFromData = parseProps(gstr)
|
|
60
60
|
return getValidWebflowAnimationProps(propsFromData)
|
|
61
61
|
}
|
package/scripts/showup/ShowUp.js
CHANGED
|
@@ -74,7 +74,7 @@ class ShowUp {
|
|
|
74
74
|
if (wfp.show) {
|
|
75
75
|
const smsp = getScrollMagicSceneProps(el, setup)
|
|
76
76
|
const scene = new ScrollMagic.Scene(smsp)
|
|
77
|
-
scene.setTween(TweenMax.from(el, wfp.show.time, wfp.show.tween))
|
|
77
|
+
scene.setTween(TweenMax.from(el, { duration: wfp.show.time, ...wfp.show.tween}))
|
|
78
78
|
scene.addTo(scrollController.get())
|
|
79
79
|
this.scenes.push(scene)
|
|
80
80
|
}
|
|
@@ -92,7 +92,7 @@ class ShowUp {
|
|
|
92
92
|
if (pp) {
|
|
93
93
|
const smsp = getScrollMagicSceneProps(el, setup)
|
|
94
94
|
const scene = new ScrollMagic.Scene(smsp)
|
|
95
|
-
scene.setTween(TweenMax.to(el, 1, pp.parallax.tween))
|
|
95
|
+
scene.setTween(TweenMax.to(el, {duration: 1, ...pp.parallax.tween}))
|
|
96
96
|
scene.addTo(scrollController.get())
|
|
97
97
|
this.scenes.push(scene)
|
|
98
98
|
}
|