Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@GENYA

javascriptのsplitで1文字ずつ分割してアニメーションさせる

“abcde”.split(‘’);の結果
スクリーンショット 2014-01-15 21.17.24.png

こんな感じの何かが出来るのではないかと。
2624d02542e1abea7634ede7034ea468.gif

文字がランダムで降ってくるとか出来そうですね。
※ つくれぽお待ちしております←

split.js


(function(){

    var text = 'Now Loading...';
        arrReceive = [];

    arrReceive = text.split('');

    console.dir(arrReceive);

    var arrLength = arrReceive.length;

    for(var i=0; i<arrLength; i++) {
        arrReceive[i] = '<span class="str-animate">'+ arrReceive[i] +'</span>';
    }


    var htmlText = arrReceive.join("");

    // アニメーション処理
    $('body').append(htmlText);


    var loop = function() {
        $('.str-animate').each(function(_idx) {
            var that = $(this);

            setTimeout(function() {
                that
                    .css({
                        position: "relative"
                    })
                    .animate({
                        top: -30
                    }, 300, function() {
                        that.animate({
                            top: 0
                        }, 300);
                    });
            }, 60*_idx);
        });
    };


    setInterval(loop, 2000);

})();


// ----------------- 参考URL
・ Myth Busting: CSS Animations vs. JavaScript
http://css-tricks.com/myth-busting-css-animations-vs-javascript/
・ CodePen Source
http://codepen.io/GreenSock/pen/AwCKp

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What are the problem?