1
+ /*
2
+ * Tadas Juozapaitis ( [email protected] )
3
+ *
4
+ * Modifed by Zazar:
5
+ * 24.06.2011 - Corrected pausing issue with multiple instances
6
+ *
7
+ */
8
+
9
+ ( function ( $ ) {
10
+
11
+ $ . fn . vTicker = function ( options ) {
12
+ var defaults = {
13
+ speed : 700 ,
14
+ pause : 4000 ,
15
+ showItems : 3 ,
16
+ animation : '' ,
17
+ mousePause : true ,
18
+ isPaused : false
19
+ } ;
20
+
21
+ var options = $ . extend ( defaults , options ) ;
22
+
23
+ moveUp = function ( obj2 , height , paused ) {
24
+ if ( paused ) return ;
25
+
26
+ var obj = obj2 . children ( 'ul' ) ;
27
+
28
+ first = obj . children ( 'li:first' ) . clone ( true ) ;
29
+
30
+ obj . animate ( { top : '-=' + height + 'px' } , options . speed , function ( ) {
31
+ $ ( this ) . children ( 'li:first' ) . remove ( ) ;
32
+ $ ( this ) . css ( 'top' , '0px' ) ;
33
+ } ) ;
34
+
35
+ if ( options . animation == 'fade' ) {
36
+ obj . children ( 'li:first' ) . fadeOut ( options . speed ) ;
37
+ obj . children ( 'li:last' ) . hide ( ) . fadeIn ( options . speed ) ;
38
+ }
39
+
40
+ first . appendTo ( obj ) ;
41
+ } ;
42
+
43
+ return this . each ( function ( ) {
44
+ var obj = $ ( this ) ;
45
+ var maxHeight = 0 ;
46
+ var itempause = options . isPaused ;
47
+
48
+ obj . css ( { overflow : 'hidden' , position : 'relative' } )
49
+ . children ( 'ul' ) . css ( { position : 'absolute' , margin : 0 , padding : 0 } )
50
+ . children ( 'li' ) . css ( { margin : 0 , padding : 0 } ) ;
51
+
52
+ obj . children ( 'ul' ) . children ( 'li' ) . each ( function ( ) {
53
+
54
+ if ( $ ( this ) . height ( ) > maxHeight ) {
55
+ maxHeight = $ ( this ) . height ( ) ;
56
+ }
57
+ } ) ;
58
+
59
+ obj . children ( 'ul' ) . children ( 'li' ) . each ( function ( ) {
60
+ $ ( this ) . height ( maxHeight ) ;
61
+ } ) ;
62
+
63
+ obj . height ( maxHeight * options . showItems ) ;
64
+
65
+ var interval = setInterval ( function ( ) { moveUp ( obj , maxHeight , itempause ) ; } , options . pause ) ;
66
+
67
+ if ( options . mousePause )
68
+ {
69
+ obj . bind ( "mouseenter" , function ( ) {
70
+ itempause = true ;
71
+ } ) . bind ( "mouseleave" , function ( ) {
72
+ itempause = false ;
73
+ } ) ;
74
+ }
75
+ } ) ;
76
+ } ;
77
+ } ) ( jQuery ) ;
0 commit comments