@canvas3/nuxt 0.1.28 → 0.1.31
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/dist/module.json +1 -1
- package/dist/runtime/directives/canvas3-scroll-action.d.ts +2 -0
- package/dist/runtime/directives/{action-on-scroll.js → canvas3-scroll-action.js} +21 -9
- package/dist/runtime/plugins/directives.js +2 -2
- package/dist/runtime/utils/canvas3/canvas3.d.ts +2 -1
- package/dist/runtime/utils/canvas3/canvas3.js +13 -0
- package/dist/runtime/utils/canvas3/scroll.js +2 -2
- package/package.json +1 -1
- package/dist/runtime/directives/action-on-scroll.d.ts +0 -2
package/dist/module.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { watch } from "vue";
|
|
2
2
|
import { Canvas3 } from "#canvas3-nuxt/utils/canvas3/canvas3";
|
|
3
|
-
export const
|
|
3
|
+
export const vCanvas3ScrollAction = {
|
|
4
4
|
mounted(el, binding) {
|
|
5
|
-
|
|
5
|
+
const id = crypto.randomUUID();
|
|
6
|
+
el.dataset.scrollActivateId = id;
|
|
6
7
|
if (binding.value?.scrollSpeedSetTo?.value) {
|
|
7
8
|
el.dataset.scrollSpeed = binding.value?.scrollSpeedSetTo?.value;
|
|
8
9
|
}
|
|
@@ -26,13 +27,24 @@ export const vOnScrollActivate = {
|
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
//* ************************
|
|
31
|
+
// DEACTIVATE UPDATES - no need as uniforms are reference based and do not need updates
|
|
32
|
+
// updated(el, binding) {
|
|
33
|
+
// const existingElement = Canvas3.getScrollActiveElement(el.dataset.scrollActivateId)
|
|
34
|
+
// if (existingElement) {
|
|
35
|
+
// const oldBinding = existingElement.options
|
|
36
|
+
//
|
|
37
|
+
// const isSame = shallowEqualObject(binding.value, oldBinding)
|
|
38
|
+
// if (!isSame) {
|
|
39
|
+
// console.log('isSame', isSame, el.dataset.scrollActivateId)
|
|
40
|
+
// Canvas3.updateOnScrollActiveElement({
|
|
41
|
+
// elNode: el,
|
|
42
|
+
// options: binding.value,
|
|
43
|
+
// arg: binding.arg,
|
|
44
|
+
// })
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// },
|
|
36
48
|
unmounted(el) {
|
|
37
49
|
Canvas3.removeScrollActiveElement(el);
|
|
38
50
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { vCanvas3ScrollAction } from "../directives/canvas3-scroll-action.js";
|
|
2
2
|
import { vSetDataAttribute } from "../directives/set-data-attributes.js";
|
|
3
3
|
import { vCanvas3Image } from "../directives/canvas3-image.client.js";
|
|
4
4
|
import { defineNuxtPlugin } from "#app";
|
|
5
5
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
6
|
-
nuxtApp.vueApp.directive("
|
|
6
|
+
nuxtApp.vueApp.directive("canvas3-scroll-action", vCanvas3ScrollAction);
|
|
7
7
|
nuxtApp.vueApp.directive("set-data-attributes", vSetDataAttribute);
|
|
8
8
|
nuxtApp.vueApp.directive("canvas3-image", vCanvas3Image);
|
|
9
9
|
});
|
|
@@ -4,7 +4,7 @@ import type { Pass } from 'three/addons/postprocessing/Pass.js';
|
|
|
4
4
|
import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
|
|
5
5
|
import type { ShaderMaterial, WebGLRenderer } from 'three';
|
|
6
6
|
import Scroll from '#canvas3-nuxt/utils/canvas3/scroll';
|
|
7
|
-
import type { AnimationCallbacks, Canvas3OptionsType, ScrollActionBinding, MeshMaterialUniform, MeshType, myEffectType, AnimationCallSetup } from '#canvas3-nuxt/types/types';
|
|
7
|
+
import type { AnimationCallbacks, Canvas3OptionsType, ScrollActionBinding, MeshMaterialUniform, MeshType, myEffectType, AnimationCallSetup, ScrollActionType } from '#canvas3-nuxt/types/types';
|
|
8
8
|
declare class Canvas3Class {
|
|
9
9
|
canvasInitiated: import("vue").Ref<boolean, boolean>;
|
|
10
10
|
renderDisabled: boolean;
|
|
@@ -49,6 +49,7 @@ declare class Canvas3Class {
|
|
|
49
49
|
meshUniformsUpdate(id: string, uniforms: MeshMaterialUniform): void;
|
|
50
50
|
activateMesh(meshId: string, isActive: boolean): void;
|
|
51
51
|
addOnScrollActivateElement(binding: ScrollActionBinding): void;
|
|
52
|
+
getScrollActiveElement(scrollActiveElementId: string): ScrollActionType | undefined;
|
|
52
53
|
updateOnScrollActiveElement(updatedBinding: ScrollActionBinding): void;
|
|
53
54
|
removeScrollActiveElement(elNode: HTMLElement): void;
|
|
54
55
|
removeMesh(id: string): void;
|
|
@@ -206,6 +206,19 @@ class Canvas3Class {
|
|
|
206
206
|
const newBinding = generateBindingLogic(binding);
|
|
207
207
|
this.scroll?.DOM.onScrollActivateElements.push(newBinding);
|
|
208
208
|
}
|
|
209
|
+
getScrollActiveElement(scrollActiveElementId) {
|
|
210
|
+
if (!this.scroll) return;
|
|
211
|
+
let scrollActiveElement;
|
|
212
|
+
for (const [
|
|
213
|
+
index,
|
|
214
|
+
item
|
|
215
|
+
] of this.scroll.DOM.onScrollActivateElements.entries()) {
|
|
216
|
+
if (item.elNode.dataset.scrollActivateId === scrollActiveElementId) {
|
|
217
|
+
scrollActiveElement = this.scroll.DOM.onScrollActivateElements[index];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return scrollActiveElement;
|
|
221
|
+
}
|
|
209
222
|
updateOnScrollActiveElement(updatedBinding) {
|
|
210
223
|
if (!this.scroll) return;
|
|
211
224
|
for (const [
|
|
@@ -99,12 +99,12 @@ export default class Scroll {
|
|
|
99
99
|
if (item.options.onScrollCallback && this.scrollInProgress) {
|
|
100
100
|
item.options.onScrollCallback(item, this.speed, this.current);
|
|
101
101
|
}
|
|
102
|
-
if (!item.isInView
|
|
102
|
+
if (!item.isInView) {
|
|
103
103
|
item.isInView = true;
|
|
104
104
|
this.setElementActive(item, true);
|
|
105
105
|
}
|
|
106
106
|
} else {
|
|
107
|
-
if (item.isInView) {
|
|
107
|
+
if (item.isInView && !item.options.activateOnce) {
|
|
108
108
|
item.isInView = false;
|
|
109
109
|
this.setElementActive(item, false);
|
|
110
110
|
}
|
package/package.json
CHANGED