MCPcopy Create free account
hub / github.com/Fiddle-Digital/string-scroll / StringAnimation

Class StringAnimation

src/Animations/StringAnimation.ts:6–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import { StringAnimationData } from "./StringAnimationData";
5
6export class StringAnimation{
7 protected _key: string
8 get key(){
9 return this._key
10 }
11
12 protected _status: boolean = true
13 get status(){
14 return this._status
15 }
16 set status(value: boolean){
17 this._status = value
18 if(this._status){
19 this.onScrollEvent = (data: any)=>{
20 this.objectsArray.forEach((object: StringScrollObject) => {
21 if(this.onScroll != null){
22 if (object.enabled ) {
23 let progress = this.onScroll(object, data)
24 object.progress = progress
25 this.eventManager.emit(`progress_${object.key}_${object.id}`, object.progress)
26 object.el.style.setProperty(object.key, progress.toString())
27 object.connects.forEach(connect => {
28 connect.progress = progress
29 connect.el.style.setProperty(object.key, progress.toString())
30 this.eventManager.emit(`progress_${object.key}_${object.id}`, object.progress)
31 });
32 }
33 }
34 });
35 }
36 } else {
37 this.onScrollEvent = (data: any)=>{ }
38 }
39 }
40
41 private onScrollEvent = (data: any)=>{}
42 protected progressKey: string
43 protected progressFactorKey: string
44 protected bufferProgressKey: string
45 private id: number = 1
46 protected objectsMap: Map<string, StringScrollObject> = new Map<string, StringScrollObject>()
47 protected objectsArray: Array<StringScrollObject> = new Array<StringScrollObject>()
48 public allObjects: Map<string, StringScrollObject> = new Map<string, StringScrollObject>()
49 protected onUpdate: ((element: StringScrollObject, data: StringAnimationData) => number) | null = null
50 protected onScroll: ((element: StringScrollObject, data: StringAnimationData) => number) | null = null
51 protected onEnter: (element: StringScrollObject, data: StringAnimationData | null) => void = (element: StringScrollObject, data: StringAnimationData | null)=>{}
52 protected onLeave: (element: StringScrollObject, data: StringAnimationData | null) => void = (element: StringScrollObject, data: StringAnimationData | null)=>{}
53 public eventManager: EventManager = new EventManager()
54
55 constructor(key: string = "", progressKey: string = "", progressFactorKey: string = "", bufferProgressKey: string = "data-string-progress-value"){
56 this._key = key
57 this.progressKey = progressKey
58 this.progressFactorKey = progressFactorKey
59 this.bufferProgressKey = bufferProgressKey
60 this.status = true
61 }
62 get(id: string): StringScrollObject | undefined{
63 // return this.objectsMap.has(id) ? this.objectsMap.get(id) : undefined

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected