MCPcopy Create free account
hub / github.com/codrops/OnScrollShapeMorph / setupAnimationDefaults

Function setupAnimationDefaults

js/index.js:28–66  ·  view source on GitHub ↗
(itemElement, options)

Source from the content-addressed store, hash-verified

26
27// Sets up default animation settings and merges with options
28const setupAnimationDefaults = (itemElement, options) => {
29 // Default settings for clip paths and scroll trigger
30 let defaults = {
31 clipPaths: {
32 step1: {
33 initial: 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)',
34 final: 'polygon(50% 0%, 50% 50%, 50% 50%, 50% 100%)',
35 },
36 step2: {
37 initial: 'polygon(50% 50%, 50% 0%, 50% 100%, 50% 50%)',
38 final: 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)',
39 }
40 },
41 // Default scroll trigger settings
42 scrollTrigger: {
43 trigger: itemElement,
44 start: 'top 50%',
45 end: '+=50%',
46 scrub: true,
47 },
48 // Default perspective setting
49 perspective: false
50 };
51
52 // Merge defaults with options provided
53 if (options && options.scrollTrigger) {
54 defaults.scrollTrigger = {
55 ...defaults.scrollTrigger,
56 ...options.scrollTrigger
57 };
58 }
59
60 // Merge and return the complete settings
61 return {
62 ...defaults,
63 ...options,
64 scrollTrigger: defaults.scrollTrigger
65 };
66};
67
68// Prepares text within an element for animation by splitting it into characters and setting their initial opacity.
69const prepareTextForAnimation = itemElement => {

Callers 7

fx1Function · 0.85
fx2Function · 0.85
fx3Function · 0.85
fx4Function · 0.85
fx5Function · 0.85
fx6Function · 0.85
fxIntroFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected