File tree Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ public function run()
35
35
Html::tag (
36
36
'i ' ,
37
37
'' ,
38
- ['class ' =>'glyphicon glyphicon-menu-up scroll-top-circle ' ]
38
+ ['class ' =>'glyphicon glyphicon-menu-up bluezed- scroll-top-circle ' ]
39
39
),
40
40
'# ' ,
41
- ['id ' =>'btn-top-scroller ' , 'class ' =>'scroll-top ' ]
41
+ ['id ' =>'btn-top-scroller ' , 'class ' =>'bluezed- scroll-top ' ]
42
42
);
43
43
}
44
44
}
Original file line number Diff line number Diff line change 4
4
* @license https://github.com/bluezed/yii2-scroll-top/blob/master/LICENSE
5
5
*/
6
6
7
- .scroll-top {
7
+ .bluezed- scroll-top {
8
8
position : fixed;
9
9
bottom : 10px ;
10
10
right : 15px ;
13
13
text-align : center;
14
14
}
15
15
16
- .scroll-top-circle {
16
+ .bluezed- scroll-top-circle {
17
17
border-radius : 50% ;
18
18
width : 25px ;
19
19
height : 25px ;
23
23
color : # ffffff ;
24
24
}
25
25
26
- .scroll-top-circle : hover {
26
+ .bluezed- scroll-top-circle: hover {
27
27
background-color : # 666666 ;
28
28
}
Original file line number Diff line number Diff line change 6
6
7
7
$ ( function ( ) {
8
8
9
- var btnScroller = $ ( "#btn-top-scroller" ) ;
9
+ var btnScroller = $ ( '#btn-top-scroller' ) ;
10
+ var scrollerTriggerPoint = $ ( 'html, body' ) . offset ( ) . top + 150 ;
10
11
11
- $ ( document ) . on ( " scroll" , function ( ) {
12
- var top = $ ( "html, body" ) . offset ( ) . top ;
13
- if ( $ ( window ) . scrollTop ( ) > top + 150 ) {
12
+ $ ( document ) . on ( ' scroll' , function ( ) {
13
+ var pos = $ ( window ) . scrollTop ( ) ;
14
+ if ( pos > scrollerTriggerPoint && ! btnScroller . is ( ':visible' ) ) {
14
15
btnScroller . fadeIn ( ) ;
15
- } else {
16
+ } else if ( pos < scrollerTriggerPoint && btnScroller . is ( ':visible' ) ) {
16
17
btnScroller . fadeOut ( ) ;
17
18
}
18
19
} ) ;
19
20
20
- btnScroller . on ( " click" , function ( e ) {
21
+ btnScroller . on ( ' click' , function ( e ) {
21
22
e . preventDefault ( ) ;
22
- $ ( " html, body" ) . animate ( { scrollTop : 0 } , 300 ) ;
23
+ $ ( ' html, body' ) . animate ( { scrollTop : 0 } , 300 ) ;
23
24
} ) ;
24
25
25
26
} ) ;
You can’t perform that action at this time.
0 commit comments