1
+ /**
2
+ * jQuery scroroller Plugin 1.0
3
+ *
4
+ * http://www.tinywall.net/
5
+ *
6
+ * Developers: Arun David, Boobalan
7
+ * Copyright (c) 2014
8
+ */
9
+ ( function ( $ ) {
10
+ $ ( window ) . on ( "load" , function ( ) {
11
+ $ ( document ) . scrollzipInit ( ) ;
12
+ $ ( document ) . rollerInit ( ) ;
13
+ } ) ;
14
+ $ ( window ) . on ( "load scroll resize" , function ( ) {
15
+ $ ( '.numscroller' ) . scrollzip ( {
16
+ showFunction : function ( ) {
17
+ numberRoller ( $ ( this ) . attr ( 'data-slno' ) ) ;
18
+ } ,
19
+ wholeVisible : false ,
20
+ } ) ;
21
+ } ) ;
22
+ $ . fn . scrollzipInit = function ( ) {
23
+ $ ( 'body' ) . prepend ( "<div style='position:fixed;top:0px;left:0px;width:0;height:0;' id='scrollzipPoint'></div>" ) ;
24
+ } ;
25
+ $ . fn . rollerInit = function ( ) {
26
+ var i = 0 ;
27
+ $ ( '.numscroller' ) . each ( function ( ) {
28
+ i ++ ;
29
+ $ ( this ) . attr ( 'data-slno' , i ) ;
30
+ $ ( this ) . addClass ( "roller-title-number-" + i ) ;
31
+ } ) ;
32
+ } ;
33
+ $ . fn . scrollzip = function ( options ) {
34
+ var settings = $ . extend ( {
35
+ showFunction : null ,
36
+ hideFunction : null ,
37
+ showShift : 0 ,
38
+ wholeVisible : false ,
39
+ hideShift : 0 ,
40
+ } , options ) ;
41
+ return this . each ( function ( i , obj ) {
42
+ $ ( this ) . addClass ( 'scrollzip' ) ;
43
+ if ( $ . isFunction ( settings . showFunction ) ) {
44
+ if (
45
+ ! $ ( this ) . hasClass ( 'isShown' ) &&
46
+ ( $ ( window ) . outerHeight ( ) + $ ( '#scrollzipPoint' ) . offset ( ) . top - settings . showShift ) > ( $ ( this ) . offset ( ) . top + ( ( settings . wholeVisible ) ?$ ( this ) . outerHeight ( ) :0 ) ) &&
47
+ ( $ ( '#scrollzipPoint' ) . offset ( ) . top + ( ( settings . wholeVisible ) ?$ ( this ) . outerHeight ( ) :0 ) ) < ( $ ( this ) . outerHeight ( ) + $ ( this ) . offset ( ) . top - settings . showShift )
48
+ ) {
49
+ $ ( this ) . addClass ( 'isShown' ) ;
50
+ settings . showFunction . call ( this ) ;
51
+ }
52
+ }
53
+ if ( $ . isFunction ( settings . hideFunction ) ) {
54
+ if (
55
+ $ ( this ) . hasClass ( 'isShown' ) &&
56
+ ( ( $ ( window ) . outerHeight ( ) + $ ( '#scrollzipPoint' ) . offset ( ) . top - settings . hideShift ) < ( $ ( this ) . offset ( ) . top + ( ( settings . wholeVisible ) ?$ ( this ) . outerHeight ( ) :0 ) ) ||
57
+ ( $ ( '#scrollzipPoint' ) . offset ( ) . top + ( ( settings . wholeVisible ) ?$ ( this ) . outerHeight ( ) :0 ) ) > ( $ ( this ) . outerHeight ( ) + $ ( this ) . offset ( ) . top - settings . hideShift ) )
58
+ ) {
59
+ $ ( this ) . removeClass ( 'isShown' ) ;
60
+ settings . hideFunction . call ( this ) ;
61
+ }
62
+ }
63
+ return this ;
64
+ } ) ;
65
+ } ;
66
+ function numberRoller ( slno ) {
67
+ var min = $ ( '.roller-title-number-' + slno ) . attr ( 'data-min' ) ;
68
+ var max = $ ( '.roller-title-number-' + slno ) . attr ( 'data-max' ) ;
69
+ var timediff = $ ( '.roller-title-number-' + slno ) . attr ( 'data-delay' ) ;
70
+ var increment = $ ( '.roller-title-number-' + slno ) . attr ( 'data-increment' ) ;
71
+ var numdiff = max - min ;
72
+ var timeout = ( timediff * 1000 ) / numdiff ;
73
+ //if(numinc<10){
74
+ //increment=Math.floor((timediff*1000)/10);
75
+ //}//alert(increment);
76
+ numberRoll ( slno , min , max , increment , timeout ) ;
77
+
78
+ }
79
+ function numberRoll ( slno , min , max , increment , timeout ) { //alert(slno+"="+min+"="+max+"="+increment+"="+timeout);
80
+ if ( min <= max ) {
81
+ $ ( '.roller-title-number-' + slno ) . html ( min ) ;
82
+ min = parseInt ( min ) + parseInt ( increment ) ;
83
+ setTimeout ( function ( ) { numberRoll ( eval ( slno ) , eval ( min ) , eval ( max ) , eval ( increment ) , eval ( timeout ) ) } , timeout ) ;
84
+ } else {
85
+ $ ( '.roller-title-number-' + slno ) . html ( max ) ;
86
+ }
87
+ }
88
+ } ) ( jQuery ) ;
0 commit comments