OSDN Git Service

.sticky class added
authoryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 23 Dec 2016 00:27:53 +0000 (09:27 +0900)
committeryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 23 Dec 2016 00:27:53 +0000 (09:27 +0900)
static/css/main.css
static/js/sub.js

index ea149ab..9ca4299 100755 (executable)
@@ -53,11 +53,16 @@ header textarea {
 }\r
 \r
 button {\r
-       position:fixed;\r
+       position:relative;\r
        width:80px;\r
        height:30px\r
 }\r
 \r
+button.sticky {\r
+       position:fixed;\r
+       top:0\r
+}\r
+\r
 input[type=password] {\r
     width:55px\r
 }\r
index 6c9be0b..e77d553 100644 (file)
@@ -38,18 +38,15 @@ $(function(){
        $window.on('scroll',function(){
                var wintop = $window.scrollTop();
                
-               if ($header.hasClass('open')){
-                       if (wintop < headerOffsetTop){
-                               $headerCloneContainer.css({opacity:0,top:-headerHeight});
-                               $header.removeClass('open');
-                               $window.trigger('scroll');
-                       };
+               if ($header.hasClass('open')&&(wintop < headerOffsetTop)){
+                       $headerCloneContainer.css({opacity:0,top:-headerHeight});
+                       $header.removeClass('open');
+                       $window.trigger('scroll');
+               };
+               if (wintop > headerOffsetTop+headerHeight){
+                       $button.addClass('sticky');
                }else{
-                       if (wintop < headerOffsetTop+headerHeight){
-                               $button.css({top:-wintop+headerOffsetTop+headerHeight});
-                       }else{
-                               $button.css({top:0});
-                       };
+                       $button.removeClass('sticky');
                };
        });
 });
\ No newline at end of file