Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

innerHTML #2

Open
lasrtb opened this issue Dec 17, 2019 · 0 comments
Open

innerHTML #2

lasrtb opened this issue Dec 17, 2019 · 0 comments

Comments

@lasrtb
Copy link

lasrtb commented Dec 17, 2019

the letter animation JS should be changed from getting the innerHTML to getting the innerText and filter out the tags that are not text as if you have let's say an icon in the div till be displayed with all the tags etc
I changed mine to this and works well (needs a bit tweaking it's just for the idea)

function animateSequence() {
    var a = $('.sequence');
    for (var i = 0; i < a.length; i++) {
        var $this = a[i];
        var letter = $('.sequence').not($('.sequence').children()).text()
        letter = letter.trim();
        var str = '';
        var delay = 100;
        for (l = 0; l < letter.length; l++) {
            if (letter[l] != ' ') {
                str += '<span style="animation-delay:' + delay + 'ms; -moz-animation-delay:' + delay + 'ms; -webkit-animation-delay:' + delay + 'ms; ">' + letter[l] + '</span>';
                delay += 150;
            } else
                str += letter[l];
        }
        $this.innerHTML = str;
    }
}

function animateRandom() {
    var a = $('.random');
    for (var i = 0; i < a.length; i++) {
        var $this = a[i];
        var letter = $('.random').not($('.random').children()).text()
        letter = letter.trim();
        var delay = 70;
        var delayArray = new Array;
        var randLetter = new Array;
        for (j = 0; j < letter.length; j++) {
            while (1) {
                var random = getRandomInt(0, (letter.length - 1));
                if (delayArray.indexOf(random) == -1)
                    break;
            }
            delayArray[j] = random;
        }
        for (l = 0; l < delayArray.length; l++) {
            var str = '';
            var index = delayArray[l];
            if (letter[index] != ' ') {
                str = '<span style="animation-delay:' + delay + 'ms; -moz-animation-delay:' + delay + 'ms; -webkit-animation-delay:' + delay + 'ms; ">' + letter[index] + '</span>';
                randLetter[index] = str;
            } else
                randLetter[index] = letter[index];
            delay += 80;
        }
        randLetter = randLetter.join("");
        $this.innerHTML = randLetter;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant