PageSourceSearch

https://upperhand.com/wp-content/plugins/droit-elementor-addons/as…/animation/animated_heading.js?ver=3.1.5

js upperhand.com collected 2026-10-01 14:03:33 UTC 8,232 bytes, 181 lines download raw bytes

1;(function($, w) { 
2    w.droitAnimatedText = function(options) {
3        var defaults = {
4            selector: '.dl_animated_headline',
5            animationDelay: 2500,
6            //loading bar effect
7            barAnimationDelay: 3800,
8            //barWaiting: this.barAnimationDelay - 3000, //3000 is the duration of the transition on the loading bar - set in the scss/css file
9            //letters effect
10            lettersDelay: 50,
11            //type effect
12            typeLettersDelay: 150,
13            selectionDuration: 500,
14            //typeAnimationDelay: this.selectionDuration + 800,
15            //clip effect
16            revealDuration: 600,
17            revealAnimationDelay: 1500
18        };
19
20        options = $.extend(defaults, options);
21
22        var $selector = $(options.selector),
23            animationDelay = options.animationDelay,
24            barAnimationDelay = options.barAnimationDelay,
25            // barWaiting = options.barWaiting,
26            barWaiting = barAnimationDelay - 3000,
27            lettersDelay = options.lettersDelay,
28            typeLettersDelay = options.typeLettersDelay,
29            selectionDuration = options.selectionDuration,
30            // typeAnimationDelay = options.typeAnimationDelay,
31            typeAnimationDelay = selectionDuration + 800,
32            revealDuration = options.revealDuration,
33            revealAnimationDelay = options.revealAnimationDelay;
34
35        //console.log(animationDelay);
36
37        //initialise headline animation
38        animateHeadline($selector);
39        //insert <i> element for each letter of a changing word
40        $selector.hasClass('letters') && singleLetters($selector.find('b'));
41
42        function singleLetters($words) {
43            $words.each(function(){
44                var word = $(this),
45                    letters = word.text().split(''),
46                    selected = word.hasClass('is-visible'),
47                    isRotate2 = word.parents('.rotate-2').length;
48
49                for (i in letters) {
50                    var letter = ! $.trim(letters[i]) ? '&nbsp;' : letters[i];
51
52                    if ( isRotate2 ) {
53                        letter = '<em>' + letter + '</em>';
54                    }
55
56                    if ( selected ) {
57                        letters[i] = '<i class="in">' + letter + '</i>'
58                    } else {
59                        letters[i] = '<i>' + letter + '</i>'
60                    }
61                }
62
63                word.html( letters.join('') ).css('opacity', 1);
64            });
65        }
66
67        function animateHeadline($headlines) {
68            var duration = animationDelay;
69            $headlines.each(function(){
70                var headline = $(this);
71
72                if(headline.hasClass('loading-bar')) {
73                    duration = barAnimationDelay;
74                    setTimeout(function(){ headline.find('.dl_words_wrapper').addClass('is-loading') }, barWaiting);
75                } else if (headline.hasClass('clip')){
76                    var spanWrapper = headline.find('.dl_words_wrapper'),
77                        newWidth = spanWrapper.width() + 10
78                    spanWrapper.css('width', newWidth);
79                } else if (!headline.hasClass('type') ) {
80                    //assign to .dl_words_wrapper the width of its longest word
81                    var words = headline.find('.dl_words_wrapper b'),
82                        width = 0;
83                    words.each(function(){
84                        var wordWidth = $(this).width();
85                        if (wordWidth > width) width = wordWidth;
86                    });
87                    headline.find('.dl_words_wrapper').css('width', width);
88                };
89
90                //trigger animation
91                setTimeout(function(){ hideWord( headline.find('.is-visible').eq(0) ) }, duration);
92            });
93        }
94
95        function hideWord($word) {
96            var nextWord = takeNext($word);
97
98            if($word.parents('.dl_animated_headline').hasClass('type')) {
99                var parentSpan = $word.parent('.dl_words_wrapper');
100                parentSpan.addClass('selected').removeClass('waiting');
101                setTimeout(function(){
102                    parentSpan.removeClass('selected');
103                    $word.removeClass('is-visible').addClass('is-hidden').children('i').removeClass('in').addClass('out');
104                }, selectionDuration);
105                setTimeout(function(){ showWord(nextWord, typeLettersDelay) }, typeAnimationDelay);
106
107            } else if($word.parents('.dl_animated_headline').hasClass('letters')) {
108                var bool = ($word.children('i').length >= nextWord.children('i').length) ? true : false;
109                hideLetter($word.find('i').eq(0), $word, bool, lettersDelay);
110                showLetter(nextWord.find('i').eq(0), nextWord, bool, lettersDelay);
111
112            }  else if($word.parents('.dl_animated_headline').hasClass('clip')) {
113                $word.parents('.dl_words_wrapper').animate({ width : '2px' }, revealDuration, function(){
114                    switchWord($word, nextWord);
115                    showWord(nextWord);
116                });
117
118            } else if ($word.parents('.dl_animated_headline').hasClass('loading-bar')){
119                $word.parents('.dl_words_wrapper').removeClass('is-loading');
120                switchWord($word, nextWord);
121                setTimeout(function(){ hideWord(nextWord) }, barAnimationDelay);
122                setTimeout(function(){ $word.parents('.dl_words_wrapper').addClass('is-loading') }, barWaiting);
123
124            } else {
125                switchWord($word, nextWord);
126                setTimeout(function(){ hideWord(nextWord) }, animationDelay);
127            }
128        }
129
130        function showWord($word, $duration) {
131            if($word.parents('.dl_animated_headline').hasClass('type')) {
132                showLetter($word.find('i').eq(0), $word, false, $duration);
133                $word.addClass('is-visible').removeClass('is-hidden');
134
135            }  else if($word.parents('.dl_animated_headline').hasClass('clip')) {
136                $word.parents('.dl_words_wrapper').animate({ 'width' : $word.width() + 10 }, revealDuration, function(){
137                    setTimeout(function(){ hideWord($word) }, revealAnimationDelay);
138                });
139            }
140        }
141
142        function hideLetter($letter, $word, $bool, $duration) {
143            $letter.removeClass('in').addClass('out');
144
145            if(!$letter.is(':last-child')) {
146                setTimeout(function(){ hideLetter($letter.next(), $word, $bool, $duration); }, $duration);
147            } else if($bool) {
148                setTimeout(function(){ hideWord(takeNext($word)) }, animationDelay);
149            }
150
151            if($letter.is(':last-child') && $('html').hasClass('no-csstransitions')) {
152                var nextWord = takeNext($word);
153                switchWord($word, nextWord);
154            }
155        }
156
157        function showLetter($letter, $word, $bool, $duration) {
158            $letter.addClass('in').removeClass('out');
159
160            if(!$letter.is(':last-child')) {
161                setTimeout(function(){ showLetter($letter.next(), $word, $bool, $duration); }, $duration);
162            } else {
163                if($word.parents('.dl_animated_headline').hasClass('type')) { setTimeout(function(){ $word.parents('.dl_words_wrapper').addClass('waiting'); }, 200);}
164                if(!$bool) { setTimeout(function(){ hideWord($word) }, animationDelay) }
165            }
166        }
167
168        function takeNext($word) {
169            return (!$word.is(':last-child')) ? $word.next() : $word.parent().children().eq(0);
170        }
171
172        function takePrev($word) {
173            return (!$word.is(':first-child')) ? $word.prev() : $word.parent().children().last(
173);
174        }
175
176        function switchWord($oldWord, $newWord) {
177            $oldWord.removeClass('is-visible').addClass('is-hidden');
178            $newWord.removeClass('is-hidden').addClass('is-visible');
179        }
180    }
181}(jQuery, window));

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.