PageSourceSearch

https://berksencore.org/wp-content/plugins/animation-builder/assets/js/builder-animations.js

js berksencore.org collected 2026-10-01 15:34:40 UTC 8,184 bytes, 173 lines download raw bytes

1let animatedElements = new Set(); 
2
3function makeTransformableIfNeeded(el) {
4  if (el instanceof jQuery) {
5    el = el[0];
6  }
7
8  if (!(el instanceof Element)) return;
9
10  const display = window.getComputedStyle(el).display;
11  if (display === "inline") {
12    gsap.set(el, { display: "inline-block" });
13  }
14}
15
16window.renderAbAnimations = function(animationData, refresh = false) {
17
18    gsap.registerPlugin(ScrollTrigger);
19    const mm = gsap.matchMedia();
20    
21    if(refresh){
22        ScrollTrigger.getAll().forEach(trigger => trigger.kill());
23        gsap.globalTimeline.getChildren().forEach(tl => tl.kill());
24        animatedElements.forEach(element => {
25            gsap.set(element, { clearProps: "all" });
26        });
27        animatedElements.clear();
28    }
29    
30    const animationSets = ['global', 'page'];
31
32    animationSets.forEach(setKey => {
33
34        if (animationData[setKey]) { 
35            
36            for (const [key, properties] of Object.entries(animationData[setKey])) {
37
38                let mediaQuery = "";
39                if (properties.disable_below && properties.disable_above) {
40                    mediaQuery = `(min-width: ${properties.disable_below}px) and (max-width: ${properties.disable_above}px)`;
41                } else if (properties.disable_below) {
42                    mediaQuery = `(min-width: ${properties.disable_below}px)`;
43                } else if (properties.disable_above) {
44                    mediaQuery = `(max-width: ${properties.disable_above}px)`;
45                } else {
46                    mediaQuery = "all";
47                }
48                
49                mm.add(mediaQuery, () => {
50
51                    const stages = properties.stages;
52
53                    let scrub = false;
54                    let end_trigger_point = false;
55                    let end_trigger = false;
56                    let play_once = false;
57                    let toggle_actions =  "play play play reverse";
58
59                    if(properties.play_once){
60                        play_once = true;
61                        toggle_actions = "play none none none";
62                    }
63
64
65                    if (properties.scrub) {
66                        scrub = properties.scrub_delay ? properties.scrub_delay / 1000 : true;
67                        end_trigger_point = properties.scrub_trigger_point + " " + properties.scrub_viewport_point;
68                        end_trigger = properties.trigger;
69                    }
70
71                    
72                    jQuery(properties.trigger).each(function(){
73                        const triggerElement = this; 
74                        var selector = null;
75                        var tl = gsap.timeline({
76                            scrollTrigger: {
77                                trigger: triggerElement,
78                                start: properties.trigger_point + " " + properties.viewport_point,
79                                toggleActions: toggle_actions, 
80                                scrub: scrub,
81                                end_trigger: end_trigger,
82                                end: end_trigger_point,
83                                once: play_once
84                            }
85                        });
86
87                        if(properties.selection == 'simple'){
88                            
89                            let props = {};
90                            props.duration = .75;
91                            if (properties.opacity) props.opacity = properties.opacity / 100;
92                            if (properties.positionx) props.x = properties.positionx;
93                            if (properties.positiony) props.y = properties.positiony;
94                            if (properties.stagger) props.stagger = properties.stagger / 1000;
95                            if (properties.duration) props.duration = properties.duration / 1000;
96                            if (properties.scalex) props.scaleX = properties.scalex / 100;
97                            if (properties.scaley) props.scaleY = properties.scaley / 100;
98                            if (properties.rotate) props.rotation = properties.rotate;
99                            if (properties.color) props.color = properties.color;
100                            if (properties.backgroundColor) props.backgroundColor = properties.backgroundColor;
101                            props.onStart = function() {
102                                this.targets().forEach(el => el.classList.add("ab-animation-triggered"));
103                            }
104                            props.onReverseComplete = function() {
105                                this.targets().forEach(el => el.classList.remove("ab-animation-triggered"));
106                            }
107
108                            // Track the current element
109                            animatedElements.add(triggerElement);
110
111                            if(properties.animation_type == 'from'){
112                                makeTransformableIfNeeded(triggerElement);
113                                tl.from(triggerElement, props);
114                            }else{
115                                makeTransformableIfNeeded(triggerElement);
116                                tl.to(triggerElement, props);
117                            }
118                        }else{
119                            if(stages){
120                                stages.forEach(stage => {
121                                    let props = {};
122                                    props.duration = .75;
123                                    if (stage.opacity) props.opacity = stage.opacity / 100;
124                                    if (stage.positionx) props.x = stage.positionx;
125                                    if (stage.positiony) props.y = stage.positiony;
126                                    if (stage.stagger) props.stagger = stage.stagger / 1000;
127                                    if (stage.duration) props.duration = stage.duration / 1000;
128                                    if (stage.delay) props.delay = stage.delay / 1000;
129                                    if (stage.scalex) props.scaleX = stage.scalex / 100;
130                                    if (stage.scaley) props.scaleY = stage.scaley / 100;
131                                    if (stage.rotate) props.rotation = stage.rotate;
132                                    if (stage.color) props.color = stage.color;
133                                    if (stage.backgroundColor) props.backgroundColor = stage.backgroundColor;
134
135                                    if(stage.animate_trigger){
136                                        selector = jQuery(triggerElement);
137                                    }else if(stage.trigger_child){
138                                        selector = jQuery(triggerElement).find(stage.trigger);
139                                    } else {
140                                        selector = jQuery(stage.trigger);
141                                    }
142                                    
143                                    // Track all matched elements
144                                    selector.each(function() {
145                                        animatedElements.add(this);
146                                    });
147
148                                    if(stage.overlap){
149                                        var overlap = '<';
150                                    }else{
151                                        var overlap = '>';
152                                    }
153
154                                    if(stage.animation_type == 'from'){
155                                        makeTransformableIfNeeded(selector);
156                                        tl.from(selector, props, overlap);
157                                    }else{
158                                        makeTransformableIfNeeded(selector);
159                                        tl.to(selector, props, overlap);
160                                    }
161                                });
162                                
163                            }
164                        }
165                    });
166                    
167                });
168            }
169        }
170    });
171}
172
173renderAbAnimations(anibu);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.