11var FloatingButton = ( function ( ) {
22
33 var buttonSize = ( Math . max ( window . innerWidth , window . innerHeight ) > 768 ) ? 80 : 50 ;
4+ var getOffset = function getOffset ( offset , margin ) {
5+ return offset - margin + 'px' ;
6+ }
47 var FloatingButton = {
58 dom : null ,
69 config : {
@@ -17,8 +20,8 @@ var FloatingButton = (function() {
1720 height : this . config . size + 'px' ,
1821 borderRadius : this . config . size + 'px' ,
1922 position : 'absolute' ,
20- top : window . innerHeight - this . config . margin + 'px' ,
21- left : window . innerWidth - this . config . margin + 'px' ,
23+ top : getOffset ( document . body . clientHeight , this . config . margin ) ,
24+ left : getOffset ( document . body . clientWidth , this . config . margin ) ,
2225 opacity : this . config . inactiveOpacity
2326 } ) ;
2427
@@ -78,10 +81,10 @@ var FloatingButton = (function() {
7881
7982 var buttonRepositioned = function buttonRepositioned ( event ) {
8083 if ( parseInt ( this . dom . style . top ) + this . config . margin > window . innerHeight ) {
81- this . dom . style . top = window . innerHeight - this . config . margin + 'px' ;
84+ this . dom . style . top = getOffset ( document . body . clientHeight , this . config . margin ) ;
8285 }
8386 if ( parseInt ( this . dom . style . left ) + this . config . margin > window . innerWidth ) {
84- this . dom . style . left = window . innerWidth - this . config . margin + 'px' ;
87+ this . dom . style . left = getOffset ( document . body . clientWidth , this . config . margin ) ;
8588 }
8689 }
8790
0 commit comments