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()
3535 Html::tag (
3636 'i ' ,
3737 '' ,
38- ['class ' =>'glyphicon glyphicon-menu-up scroll-top-circle ' ]
38+ ['class ' =>'glyphicon glyphicon-menu-up bluezed- scroll-top-circle ' ]
3939 ),
4040 '# ' ,
41- ['id ' =>'btn-top-scroller ' , 'class ' =>'scroll-top ' ]
41+ ['id ' =>'btn-top-scroller ' , 'class ' =>'bluezed- scroll-top ' ]
4242 );
4343 }
4444}
Original file line number Diff line number Diff line change 44 * @license https://github.com/bluezed/yii2-scroll-top/blob/master/LICENSE
55 */
66
7- .scroll-top {
7+ .bluezed- scroll-top {
88 position : fixed;
99 bottom : 10px ;
1010 right : 15px ;
1313 text-align : center;
1414}
1515
16- .scroll-top-circle {
16+ .bluezed- scroll-top-circle {
1717 border-radius : 50% ;
1818 width : 25px ;
1919 height : 25px ;
2323 color : # ffffff ;
2424}
2525
26- .scroll-top-circle : hover {
26+ .bluezed- scroll-top-circle: hover {
2727 background-color : # 666666 ;
2828}
Original file line number Diff line number Diff line change 66
77$ ( function ( ) {
88
9- var btnScroller = $ ( "#btn-top-scroller" ) ;
9+ var btnScroller = $ ( '#btn-top-scroller' ) ;
10+ var scrollerTriggerPoint = $ ( 'html, body' ) . offset ( ) . top + 150 ;
1011
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' ) ) {
1415 btnScroller . fadeIn ( ) ;
15- } else {
16+ } else if ( pos < scrollerTriggerPoint && btnScroller . is ( ':visible' ) ) {
1617 btnScroller . fadeOut ( ) ;
1718 }
1819 } ) ;
1920
20- btnScroller . on ( " click" , function ( e ) {
21+ btnScroller . on ( ' click' , function ( e ) {
2122 e . preventDefault ( ) ;
22- $ ( " html, body" ) . animate ( { scrollTop : 0 } , 300 ) ;
23+ $ ( ' html, body' ) . animate ( { scrollTop : 0 } , 300 ) ;
2324 } ) ;
2425
2526} ) ;
You can’t perform that action at this time.
0 commit comments