<div class="scroll-on-page">
<aside id="scroll-on-page-top">
<a class="scroll-on-page-link" href="#scroll-link-1">First Scroll Link</a>
<a class="scroll-on-page-link" href="#scroll-link-2">Second Link</a>
<a class="scroll-on-page-link" href="#scroll-link-3">Last Link</a>
</aside>
<article>
<section>
<h4 id="scroll-link-1">First Target</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt?</p>
</section>
<section>
<h4 id="scroll-link-2">Second Target</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt?</p>
</section>
<section>
<h4 id="scroll-link-3">Last Target</h4>
<p>lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum aliquid necessitatibus, repudiandae veniam labore, consequatur maiores dolore unde non deleniti, aliquam minima ex nulla error eveniet vel tempore, in incidunt?</p>
<a class="scroll-on-page-link" href="#scroll-on-page-top">Back to top</a>
</section>
</article>
</div>
|
.scroll-on-page {
$base-line-height: 1.5em !default;
$base-spacing: 1.5em !default;
$action-color: #477DCA !default;
$dark-gray: #333 !default;
$large-screen: 53.75em !default;
$base-font-color: $dark-gray !default;
display: inline-block;
a {
color: $action-color;
text-decoration: none;
}
aside {
@include media($large-screen) {
@include span-columns(4);
}
}
.scroll-on-page-link {
border-bottom: 1px solid transparentize($action-color, 0.8);
display: block;
margin-right: $base-spacing;
outline: none;
padding: ($base-spacing / 2) 0;
&:last-child {
margin-bottom: $base-spacing;
}
}
article {
h4 {
margin: 0 0 0.5em 0;
}
p {
color: $base-font-color;
line-height: $base-line-height;
}
section p:last-of-type {
margin-bottom: 2em;
}
@include media($large-screen) {
@include span-columns(8);
}
}
}
// Based on code by http://codepen.io/xmark/
|
(function (jQuery) {
jQuery.mark = {
jump: function (options) {
var defaults = {
selector: 'a.scroll-on-page-link'
};
if (typeof options == 'string') {
defaults.selector = options;
}
options = jQuery.extend(defaults, options);
return jQuery(options.selector).click(function (e) {
var jumpobj = jQuery(this);
var target = jumpobj.attr('href');
var thespeed = 1000;
var offset = jQuery(target).offset().top;
jQuery('html,body').animate({
scrollTop: offset
}, thespeed, 'swing');
e.preventDefault();
});
}
};
})(jQuery);
jQuery(function(){
jQuery.mark.jump();
});
|
do (jQuery) ->
jQuery.mark = jump: (options) ->
defaults = selector: 'a.scroll-on-page-link'
if typeof options == 'string'
defaults.selector = options
options = jQuery.extend(defaults, options)
jQuery(options.selector).click (e) ->
jumpobj = jQuery(this)
target = jumpobj.attr('href')
thespeed = 1000
offset = jQuery(target).offset().top
jQuery('html,body').animate { scrollTop: offset }, thespeed, 'swing'
e.preventDefault()
return
return
jQuery ->
jQuery.mark.jump()
return
|
First Comment Title or Author
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio, aspernatur, quia modi minima debitis tempora ducimus quam vero impedit alias earum nemo error tenetur sed.
Date or details about this post