2010-11-13 127 views
0

我正在尋找一個好的垂直泡泡字幕插件。jQuery垂直泡泡字幕HTML元素

不是簡單的垂直選取框,我正在尋找一個很好的「flash like」效果插件,這是從div內容的底部到頂部順滑的元素字幕。

可能是非常好的,但我認爲這只是在我的夢中這個插件

+0

你能舉個例子嗎? – chchrist 2010-11-13 16:09:51

回答

0

你的意思是這樣The Silky Smooth Marquee插件?

+0

uhmmmmm ..... uhmmmmm ....完全沒有意思:P – memento 2010-11-13 23:25:05

+0

我的意思是我喜歡鼓泡或者有一些很好的效果:P – memento 2010-11-13 23:25:27

1

嗯,這是不是非常有效的,但是這是一個良好的開端,我認爲:

jQuery.fn.verticalMarquee = function(vertSpeed, horiSpeed) { 
    this.css('float', 'left'); 

    vertSpeed = vertSpeed || 1; 
    horiSpeed = 1/horiSpeed || 1; 

    var windowH = this.parent().height(), 
     thisH = this.height(), 
     parentW = (this.parent().width() - this.width())/2, 
     rand = Math.random() * 1000, 
     current = this; 

    this.css('margin-top', windowH + thisH); 
    this.parent().css('overflow', 'hidden'); 

    setInterval(function() { 
     current.css({ 
      marginTop: function(n, v) { 
       return parseFloat(v) - vertSpeed; 
      }, 
      marginLeft: function(n, v) { 
       return (Math.sin(new Date().getTime()/(horiSpeed * 1000) + rand) + 1) * parentW; 
      } 
     }); 
    }, 15); 

    setInterval(function() { 
     if (parseFloat(current.css('margin-top')) < -thisH) { 
      current.css('margin-top', windowH + thisH); 
     } 
    }, 250); 
}; 

$('.message').verticalMarquee(0.5, 1); 

它使用Math.sin的元素水平移動。函數verticalMarquee接受兩個參數,一個用於垂直速度,另一個用於水平速度。該函數只能在僅包含一個元素的jQuery對象上調用 - 在測試過程中,多個元素一次被動畫導致可怕的滯後。

看到一個簡單的演示在這裏:http://jsfiddle.net/CcccQ/2/