@canvas3/nuxt 0.1.27 → 0.1.30

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "canvas-nuxt-layout",
3
3
  "configKey": "canvas3Layout",
4
- "version": "0.1.27",
4
+ "version": "0.1.30",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.0"
@@ -0,0 +1,2 @@
1
+ import { type Directive } from 'vue';
2
+ export declare const vCanvas3ScrollAction: Directive;
@@ -1,8 +1,9 @@
1
1
  import { watch } from "vue";
2
2
  import { Canvas3 } from "#canvas3-nuxt/utils/canvas3/canvas3";
3
- export const vOnScrollActivate = {
3
+ export const vCanvas3ScrollAction = {
4
4
  mounted(el, binding) {
5
- el.dataset.scrollActivateId = crypto.randomUUID();
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
- updated(el, binding) {
30
- Canvas3.updateOnScrollActiveElement({
31
- elNode: el,
32
- options: binding.value,
33
- arg: binding.arg
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 { vOnScrollActivate } from "../directives/action-on-scroll.js";
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("action-on-scroll", vOnScrollActivate);
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 [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas3/nuxt",
3
- "version": "0.1.27",
3
+ "version": "0.1.30",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,2 +0,0 @@
1
- import { type Directive } from 'vue';
2
- export declare const vOnScrollActivate: Directive;