美文网首页
Bulid a danmu app

Bulid a danmu app

作者: Marks | 来源:发表于2017-05-13 19:43 被阅读10次

    Q1: 野狗云?

    Q2:$().click ??
    http://www.w3school.com.cn/jquery/event_click.asp

    Q3:$().val() ??
    http://www.w3school.com.cn/jquery/attributes_val.asp

    Q4: $().val('') ??
    https://zhidao.baidu.com/question/371961272.html

    ~~Q5: $().keypress() ~~
    http://www.w3school.com.cn/jquery/event_keypress.asp

    Q6: event.keyCode == "13" ??

    http://blog.csdn.net/woaini245693140/article/details/8514074

    Q7: $().trigger() ??
    http://www.w3school.com.cn/jquery/event_trigger.asp

    Q8:$().empty() ??
    http://www.w3school.com.cn/jquery/manipulation_empty.asp

    Q9: ref.child('message').on('child_added', function(snapshot) ??
    http://www.runoob.com/jquery/event-on.html

    Q10: $().text ??
    http://www.w3school.com.cn/jquery/manipulation_text.asp

    Q11: $().append() ??
    http://www.w3school.com.cn/jquery/manipulation_append.asp

    ~~Q12: var textObj = $("<div class=\"dm_message\"></div>"); ??~

    //按照时间规则显示弹幕内容。 
          var topMin = $('.dm_mask').offset().top;
          var topMax = topMin + $('.dm_mask').height();
          var _top = topMin;
    
          var moveObj = function(obj) {
            var _left = $('.dm_mask').width() - obj.width();
            _top = _top + 50;
            if (_top > (topMax - 50)) {
              _top = topMin;
            }
            obj.css({
              left: _left,
              top: _top,
              color: getRandomColor()
            });
            var time = 20000 + 10000 * Math.random();
            obj.animate({
              left: "-" + _left + "px"
            }, time, function() {
              obj.remove();
            });
          }
    
          var getRandomColor = function() {
            return '#' + (function(h) {
              return new Array(7 - h.length).join("0") + h
            })((Math.random() * 0x1000000 << 0).toString(16))
          }
    
          var getAndRun = function() {
            if (arr.length > 0) {
              var n = Math.floor(Math.random() * arr.length + 1) - 1;
              var textObj = $("<div>" + arr[n] + "</div>");
              $(".dm_show").append(textObj);
              moveObj(textObj);
            }
    
            setTimeout(getAndRun, 3000);
          }
    
          jQuery.fx.interval = 50;
          getAndRun();```
    
    ~~Q13:$('.dm_mask').offset().top;   ??~~
    http://www.bubuko.com/infodetail-928979.html
    http://www.w3school.com.cn/jquery/css_offset.asp
    
    ~~Q14:moveObj(textObj);   ??~~
    
    ~~Q15: jQuery.fx.interval  ??~~
    http://www.w3school.com.cn/jquery/prop_jquery_fx_interval.asp
    
    ~~Q: Math.random() * 0x1000000 << 0  ??~~
    

    var getRandomColor = function() {
    return '#' + (function(h) {
    return new Array(7 - h.length).join("0") + h
    })((Math.random() * 0x1000000 << 0).toString(16))
    }```
    http://www.neatstudio.com/archives/?article-1008.html 实现5和实现6

    Q: ??

    Q: ??

    相关文章

      网友评论

          本文标题:Bulid a danmu app

          本文链接:https://www.haomeiwen.com/subject/cjxxxxtx.html