Last active
July 14, 2016 13:24
-
-
Save evanre/f6a99e46bc7b3a58eaa84162b3e606ba to your computer and use it in GitHub Desktop.
Scroll to top button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| // Scroll to top button | |
| $(window).scroll(function () { | |
| if ($(this).scrollTop() > 100) { | |
| $('.scrollup').addClass('visible'); | |
| } else { | |
| $('.scrollup').removeClass('visible'); | |
| } | |
| }); | |
| $('.scrollup').click(function () { | |
| $("html, body").animate({ | |
| scrollTop: 0 | |
| }, 600); | |
| return false; | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Scroll to top | |
| .scrollup { | |
| width: 40px; | |
| height: 40px; | |
| position: fixed; | |
| transition: $transition; | |
| opacity: 0; | |
| visibility: hidden; | |
| background-color: $blackish; | |
| bottom: 5px; | |
| right: 5px; | |
| @include breakpoint(medium) { | |
| bottom: 25px; | |
| right: 25px; | |
| } | |
| @include breakpoint(large) { | |
| bottom: 50px; | |
| right: 100px; | |
| } | |
| &.visible { | |
| opacity: 1; | |
| visibility: visible; | |
| } | |
| &:hover { | |
| @include breakpoint(large) { | |
| background-color: $primary; | |
| } | |
| svg { | |
| @include breakpoint(large) { | |
| fill: $blackish; | |
| } | |
| } | |
| } | |
| span { | |
| @include element-invisible; | |
| } | |
| svg { | |
| transition: $transition; | |
| fill: $primary; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment