rytm-webflow 2.1.7 → 2.1.9
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/package.json +1 -1
- package/scripts/aswap/WebflowView.js +15 -11
- package/scripts/index.js +3 -1
- package/scripts/lib/helpers.js +10 -0
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import View from './View';
|
|
|
4
4
|
import scrollController from './../showup/ScrollController';
|
|
5
5
|
import { getWebflowAnimationProps, parseProps } from './../lib/dataTweenParser';
|
|
6
6
|
import { getScrollMagicSceneProps } from './../lib/dataScrollMagicParser';
|
|
7
|
+
import { elementIsVisibleInViewport } from '../lib/helpers'
|
|
7
8
|
|
|
8
9
|
// data-webview-... (aswap show / hide)
|
|
9
10
|
const DATA_ATTR_WEBVIEW_INIT = "webview-initial";
|
|
@@ -216,18 +217,21 @@ class WebflowView extends View {
|
|
|
216
217
|
});
|
|
217
218
|
// on scene add event
|
|
218
219
|
scene.on("add", (e) => {
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
// wait 10ms before checking if element is in view
|
|
221
|
+
// due to asap scroll position reset
|
|
222
|
+
setTimeout(() => {
|
|
222
223
|
// element is in view - animate IN
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
224
|
+
if (elementIsVisibleInViewport(el, true)) {
|
|
225
|
+
console.log("Timeout", el);
|
|
226
|
+
gsap.to(el, {
|
|
227
|
+
duration: propsShow.time,
|
|
228
|
+
...propsShow.tween,
|
|
229
|
+
onComplete: () => {
|
|
230
|
+
el.classList.add(CLASS_NAME_WEBSCROLL_FIRED);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}, 10);
|
|
231
235
|
});
|
|
232
236
|
scene.addTo(scrollController.get());
|
|
233
237
|
this.scenes.push(scene);
|
package/scripts/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import scrollController from './showup/ScrollController'
|
|
|
11
11
|
import showUp from './showup/ShowUp'
|
|
12
12
|
import { getWebflowAnimationProps, getWebflowProps, getParallaxProps, parseProps } from './lib/dataTweenParser'
|
|
13
13
|
import { getScrollMagicSceneProps } from './lib/dataScrollMagicParser'
|
|
14
|
+
import { elementIsVisibleInViewport } from './lib/helpers'
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
aswap: aswapInstance,
|
|
@@ -29,5 +30,6 @@ export default {
|
|
|
29
30
|
getWebflowProps,
|
|
30
31
|
getParallaxProps,
|
|
31
32
|
parseProps,
|
|
32
|
-
getScrollMagicSceneProps
|
|
33
|
+
getScrollMagicSceneProps,
|
|
34
|
+
elementIsVisibleInViewport,
|
|
33
35
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
export const elementIsVisibleInViewport = (el, partiallyVisible = true) => {
|
|
3
|
+
const { top, left, bottom, right } = el.getBoundingClientRect();
|
|
4
|
+
const { innerHeight, innerWidth } = window;
|
|
5
|
+
return partiallyVisible
|
|
6
|
+
? ((top > 0 && top < innerHeight) ||
|
|
7
|
+
(bottom > 0 && bottom < innerHeight)) &&
|
|
8
|
+
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
|
9
|
+
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
|
10
|
+
}
|