rytm-webflow 2.0.8 → 2.1.0
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 +28 -5
- package/package.json +1 -1
- package/scripts/aswap/WebflowListView.js +77 -0
- package/scripts/index.js +2 -0
- package/scripts/lib/dataTweenParser.js +5 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
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).
|
|
4
|
+
This package comes with a handy [WebflowView](#webflowview) and [WebflowListView](#webflowlistview).
|
|
5
5
|
Another future rytm-webflow includes is [ShowUp](#showup) - a ScrollMagic.js wrapper which can be integrated with ASwap.
|
|
6
6
|
|
|
7
7
|
|
|
@@ -250,7 +250,7 @@ Animate any element within the *WebflowView* container using the **Webflow synta
|
|
|
250
250
|
```
|
|
251
251
|
or (more complex example):
|
|
252
252
|
```html
|
|
253
|
-
<div data-webview-initial="x:-10,y:50" data-webview-show="x:0,y:0,t:.5,d:.15,e:
|
|
253
|
+
<div data-webview-initial="x:-10,y:50" data-webview-show="x:0,y:0,t:.5,d:.15,e:power3.out" data-webview-hide="x:10,y:-25,t:.4,d:.2,e:power2.in">
|
|
254
254
|
...
|
|
255
255
|
</div>
|
|
256
256
|
```
|
|
@@ -269,7 +269,30 @@ Scroll-triggered-animations of any element inside the *WebflowView* container. U
|
|
|
269
269
|
...
|
|
270
270
|
</div>
|
|
271
271
|
```
|
|
272
|
+
## <a name="webflowlistview">WebflowListView</a> ##
|
|
273
|
+
The WebflowListView enables staggered *show* animation for elements which implement the WebflowView Scrollmagic animations.
|
|
274
|
+
### Basic usage example
|
|
275
|
+
Define the route:
|
|
276
|
+
```js
|
|
277
|
+
import RytmWebflow from 'rytm-webflow'
|
|
272
278
|
|
|
279
|
+
RytmWebflow.aswap.init({
|
|
280
|
+
routes: {
|
|
281
|
+
"list" : {
|
|
282
|
+
controller: RytmWebflow.Controller,
|
|
283
|
+
view: RytmWebflow.WebflowListView
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
Add data attributes to the cointainer element. Inside the container place elements that include the `webscroll` data attributes (initial, show, hide):
|
|
289
|
+
```html
|
|
290
|
+
<div id="stage">
|
|
291
|
+
<ul data-as-view="list" data-as-id="uid" data-webset="selector:li,stagger:.1">
|
|
292
|
+
<li data-webscroll-initial="o:0" data-webscroll-show="o:1,t:.5" data-webscroll-hide="o:0,t.4">...</li>
|
|
293
|
+
</ul>
|
|
294
|
+
</div>
|
|
295
|
+
```
|
|
273
296
|
|
|
274
297
|
|
|
275
298
|
## <a name="showup">ShowUp</a> ##
|
|
@@ -300,7 +323,7 @@ To implement ShowUp on your HTML add a `data-webflow` or `data-webpara` attribut
|
|
|
300
323
|
Add easing for your animations
|
|
301
324
|
```html
|
|
302
325
|
<!-- gsap easing -->
|
|
303
|
-
<div data-webflow="x:-10vw,t:.5,e:
|
|
326
|
+
<div data-webflow="x:-10vw,t:.5,e:expo.out">...</div>
|
|
304
327
|
```
|
|
305
328
|
Delay animations
|
|
306
329
|
```html
|
|
@@ -387,7 +410,7 @@ Examples:
|
|
|
387
410
|
<h1>Webflow show up</h1>
|
|
388
411
|
<div data-webflow="t:.4,o:0,y:10;t:.4,o:0,y:-30">Webflow Simple ALPHA no delay</div>
|
|
389
412
|
<div data-webflow="t:.4,o:0,s:.4;t:.4,o:0,s:1.5">Webflow Scale</div>
|
|
390
|
-
<div data-webflow="t:1.4,x:-300,e:
|
|
413
|
+
<div data-webflow="t:1.4,x:-300,e:expo.out;t:.4,d:0,x:-100,e:expo.in" data-webset="offset:100">Webflow Offset: 100, Ease EXPO</div>
|
|
391
414
|
<div data-webflow="t:1.4,x:-100vw;t:.4,d:0,x:-250" data-webset="offset:center">Webflow Offset: center</div>
|
|
392
415
|
<div data-webflow="t:1.4,x:-250;t:.4,d:0,x:-250" data-webset="offset:top">Webflow offset: TOP</div>
|
|
393
416
|
<div data-webflow="t:1.4,x:-250,w:10;t:.4,d:0,x:-250" data-webset="trigger:#boom">Webflow Triggered by next BLOCK</div>
|
|
@@ -395,7 +418,7 @@ Examples:
|
|
|
395
418
|
<!-- ### Webflow Parallax ### -->
|
|
396
419
|
<h1>Webflow parallax</h1>
|
|
397
420
|
<div data-webpara="x:400" data-webset="duration:100%">Parallax duration 100%</div>
|
|
398
|
-
<div data-webpara="x:400,e:
|
|
421
|
+
<div data-webpara="x:400,e:back.out" data-webset="duration:40vh">Parallax duration 40vh, ease: Back</div>
|
|
399
422
|
<div >parent TRIGGER
|
|
400
423
|
<div data-webpara="y:-500,r:180" data-webset="duration:100%,trigger:parent">Parallax Y</div>
|
|
401
424
|
</div>
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import gsap from 'gsap';
|
|
2
|
+
import View from './View';
|
|
3
|
+
import { getWebflowAnimationProps, parseProps } from './../lib/dataTweenParser';
|
|
4
|
+
|
|
5
|
+
// data-webscroll-... (scroll magic)
|
|
6
|
+
const DATA_ATTR_WEBSCROLL_INIT = "webscroll-initial";
|
|
7
|
+
const DATA_ATTR_WEBSCROLL_SHOW = "webscroll-show";
|
|
8
|
+
const DATA_ATTR_SETUP = "webset";
|
|
9
|
+
const DEFAULT_STAGGER = .05;
|
|
10
|
+
|
|
11
|
+
class WebflowListView extends View {
|
|
12
|
+
|
|
13
|
+
constructor(id) {
|
|
14
|
+
super(id);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* animate in (show)
|
|
18
|
+
**/
|
|
19
|
+
show(container) {
|
|
20
|
+
super.show(container);
|
|
21
|
+
this.webset = parseProps(container.dataset[DATA_ATTR_SETUP]);
|
|
22
|
+
if (!this.webset.selector) {
|
|
23
|
+
console.warn("Unknown selector for WebflowListView", this);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const list = [...container.querySelectorAll(this.webset.selector)];
|
|
27
|
+
list.forEach(this.listElementShow.bind(this));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* animate out (hide)
|
|
31
|
+
**/
|
|
32
|
+
hide(container) {
|
|
33
|
+
super.hide(container);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ############
|
|
37
|
+
* ### SHOW ###
|
|
38
|
+
* ############
|
|
39
|
+
*/
|
|
40
|
+
// show list element
|
|
41
|
+
listElementShow(el, index) {
|
|
42
|
+
const stagger = this.webset.stagger ? parseFloat(this.webset.stagger) : DEFAULT_STAGGER;
|
|
43
|
+
const delay = index * stagger;
|
|
44
|
+
// search for all webscroll elements
|
|
45
|
+
const list = [...el.querySelectorAll('*[data-' + DATA_ATTR_WEBSCROLL_SHOW + ']')];
|
|
46
|
+
list.forEach((el) => {
|
|
47
|
+
this.webScrollElementShow(el, delay);
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
// show web scroll element
|
|
51
|
+
webScrollElementShow(el, delay) {
|
|
52
|
+
const propsInitial = this.getTweenProps(el, DATA_ATTR_WEBSCROLL_INIT);
|
|
53
|
+
const propsShow = this.getTweenProps(el, DATA_ATTR_WEBSCROLL_SHOW);
|
|
54
|
+
if (propsInitial && propsShow) {
|
|
55
|
+
delay = delay + (propsShow.delay || 0);
|
|
56
|
+
gsap.killTweensOf(el);
|
|
57
|
+
gsap.set(el, {...propsInitial.tween});
|
|
58
|
+
gsap.to(el, {duration: propsShow.time, ...propsShow.tween, delay});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* ###############
|
|
63
|
+
* ### HELPERS ###
|
|
64
|
+
* ###############
|
|
65
|
+
*/
|
|
66
|
+
// get animation props
|
|
67
|
+
getTweenProps(el, name) {
|
|
68
|
+
const dataAttrName = this.getDataAttributeName(name);
|
|
69
|
+
return getWebflowAnimationProps(el.dataset[dataAttrName]);
|
|
70
|
+
}
|
|
71
|
+
// replace data-x with dataX
|
|
72
|
+
getDataAttributeName(name) {
|
|
73
|
+
return name.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
export default WebflowListView
|
package/scripts/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import Controller from './aswap/Controller'
|
|
|
3
3
|
import ControllerImgLoad from './aswap/ControllerImgLoad'
|
|
4
4
|
import View from './aswap/View'
|
|
5
5
|
import WebflowView from './aswap/WebflowView'
|
|
6
|
+
import WebflowListView from './aswap/WebflowListView'
|
|
6
7
|
// Bootstrap v5 helper
|
|
7
8
|
import bootsrap5 from './bootstrap/v5/Bootstrap5'
|
|
8
9
|
// showup
|
|
@@ -17,6 +18,7 @@ export default {
|
|
|
17
18
|
ControllerImgLoad,
|
|
18
19
|
View,
|
|
19
20
|
WebflowView,
|
|
21
|
+
WebflowListView,
|
|
20
22
|
// boottstrap
|
|
21
23
|
bootsrap5,
|
|
22
24
|
// showup
|
|
@@ -145,7 +145,10 @@ const translateNonNumericValue = (key, valStr) => {
|
|
|
145
145
|
let val
|
|
146
146
|
switch (key) {
|
|
147
147
|
case 'ease':
|
|
148
|
-
|
|
148
|
+
// old syntax: 'Back.easeOut'
|
|
149
|
+
val = getWebflowEasing(valStr);
|
|
150
|
+
// new syntax, eg.: 'back.out'
|
|
151
|
+
val = val ? val : valStr;
|
|
149
152
|
break;
|
|
150
153
|
default:
|
|
151
154
|
// by default don't change anything (eg. '100%', '50vw')
|
|
@@ -155,6 +158,7 @@ const translateNonNumericValue = (key, valStr) => {
|
|
|
155
158
|
return val
|
|
156
159
|
}
|
|
157
160
|
/**
|
|
161
|
+
* ### Depreciated (use string values insted, eg "e:back.out")
|
|
158
162
|
* Get the TweenMax Easing function
|
|
159
163
|
* @param {string} str
|
|
160
164
|
* @return {Ease}
|