speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2
+ autoCoefficent: 2,
+
+ // $.fn.smoothScroll only: whether to prevent the default click action
+ preventDefault: true
}
The options object for $.fn.smoothScroll can take two additional properties:
diff --git a/jquery.smooth-scroll.js b/jquery.smooth-scroll.js
index c8a6cb1..fe18d1d 100644
--- a/jquery.smooth-scroll.js
+++ b/jquery.smooth-scroll.js
@@ -1,5 +1,5 @@
/*!
- * Smooth Scroll - v1.4.10 - 2013-03-02
+ * Smooth Scroll - v1.4.11 - 2013-07-15
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2013 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
@@ -7,7 +7,7 @@
(function($) {
-var version = '1.4.10',
+var version = '1.4.11',
defaults = {
exclude: [],
excludeWithin:[],
@@ -34,7 +34,10 @@ var version = '1.4.10',
speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2
+ autoCoefficent: 2,
+
+ // $.fn.smoothScroll only: whether to prevent the default click action
+ preventDefault: true
},
getScrollable = function(opts) {
@@ -126,7 +129,10 @@ $.fn.extend({
}
if ( include ) {
- event.preventDefault();
+
+ if ( opts.preventDefault ) {
+ event.preventDefault();
+ }
$.extend( clickOpts, opts, {
scrollTarget: opts.scrollTarget || thisHash,
diff --git a/jquery.smooth-scroll.min.js b/jquery.smooth-scroll.min.js
index 2af596e..0853d90 100644
--- a/jquery.smooth-scroll.min.js
+++ b/jquery.smooth-scroll.min.js
@@ -1,7 +1,7 @@
/*!
- * Smooth Scroll - v1.4.10 - 2013-03-02
+ * Smooth Scroll - v1.4.11 - 2013-07-15
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2013 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
*/
-(function(l){function t(l){return l.replace(/(:|\.)/g,"\\$1")}var e="1.4.10",o={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficent:2},r=function(t){var e=[],o=!1,r=t.dir&&"left"==t.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!=document&&this!=window){var t=l(this);t[r]()>0?e.push(this):(t[r](1),o=t[r]()>0,o&&e.push(this),t[r](0))}}),e.length||this.each(function(){"BODY"===this.nodeName&&(e=[this])}),"first"===t.el&&e.length>1&&(e=[e[0]]),e};l.fn.extend({scrollable:function(l){var t=r.call(this,{dir:l});return this.pushStack(t)},firstScrollable:function(l){var t=r.call(this,{el:"first",dir:l});return this.pushStack(t)},smoothScroll:function(e){e=e||{};var o=l.extend({},l.fn.smoothScroll.defaults,e),r=l.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(e){var n=this,s=l(this),c=o.exclude,i=o.excludeWithin,a=0,f=0,h=!0,u={},d=location.hostname===n.hostname||!n.hostname,m=o.scrollTarget||(l.smoothScroll.filterPath(n.pathname)||r)===r,p=t(n.hash);if(o.scrollTarget||d&&m&&p){for(;h&&c.length>a;)s.is(t(c[a++]))&&(h=!1);for(;h&&i.length>f;)s.closest(i[f++]).length&&(h=!1)}else h=!1;h&&(e.preventDefault(),l.extend(u,o,{scrollTarget:o.scrollTarget||p,link:n}),l.smoothScroll(u))}),this}}),l.smoothScroll=function(t,e){var o,r,n,s,c=0,i="offset",a="scrollTop",f={},h={};"number"==typeof t?(o=l.fn.smoothScroll.defaults,n=t):(o=l.extend({},l.fn.smoothScroll.defaults,t||{}),o.scrollElement&&(i="position","static"==o.scrollElement.css("position")&&o.scrollElement.css("position","relative"))),o=l.extend({link:null},o),a="left"==o.direction?"scrollLeft":a,o.scrollElement?(r=o.scrollElement,c=r[a]()):r=l("html, body").firstScrollable(),o.beforeScroll.call(r,o),n="number"==typeof t?t:e||l(o.scrollTarget)[i]()&&l(o.scrollTarget)[i]()[o.direction]||0,f[a]=n+c+o.offset,s=o.speed,"auto"===s&&(s=f[a]||r.scrollTop(),s/=o.autoCoefficent),h={duration:s,easing:o.easing,complete:function(){o.afterScroll.call(o.link,o)}},o.step&&(h.step=o.step),r.length?r.stop().animate(f,h):o.afterScroll.call(o.link,o)},l.smoothScroll.version=e,l.smoothScroll.filterPath=function(l){return l.replace(/^\//,"").replace(/(index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},l.fn.smoothScroll.defaults=o})(jQuery);
\ No newline at end of file
+(function(l){function t(l){return l.replace(/(:|\.)/g,"\\$1")}var e="1.4.11",o={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficent:2,preventDefault:!0},r=function(t){var e=[],o=!1,r=t.dir&&"left"==t.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!=document&&this!=window){var t=l(this);t[r]()>0?e.push(this):(t[r](1),o=t[r]()>0,o&&e.push(this),t[r](0))}}),e.length||this.each(function(){"BODY"===this.nodeName&&(e=[this])}),"first"===t.el&&e.length>1&&(e=[e[0]]),e};l.fn.extend({scrollable:function(l){var t=r.call(this,{dir:l});return this.pushStack(t)},firstScrollable:function(l){var t=r.call(this,{el:"first",dir:l});return this.pushStack(t)},smoothScroll:function(e){e=e||{};var o=l.extend({},l.fn.smoothScroll.defaults,e),r=l.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(e){var n=this,s=l(this),c=o.exclude,i=o.excludeWithin,a=0,f=0,h=!0,u={},d=location.hostname===n.hostname||!n.hostname,m=o.scrollTarget||(l.smoothScroll.filterPath(n.pathname)||r)===r,p=t(n.hash);if(o.scrollTarget||d&&m&&p){for(;h&&c.length>a;)s.is(t(c[a++]))&&(h=!1);for(;h&&i.length>f;)s.closest(i[f++]).length&&(h=!1)}else h=!1;h&&(o.preventDefault&&e.preventDefault(),l.extend(u,o,{scrollTarget:o.scrollTarget||p,link:n}),l.smoothScroll(u))}),this}}),l.smoothScroll=function(t,e){var o,r,n,s,c=0,i="offset",a="scrollTop",f={},h={};"number"==typeof t?(o=l.fn.smoothScroll.defaults,n=t):(o=l.extend({},l.fn.smoothScroll.defaults,t||{}),o.scrollElement&&(i="position","static"==o.scrollElement.css("position")&&o.scrollElement.css("position","relative"))),o=l.extend({link:null},o),a="left"==o.direction?"scrollLeft":a,o.scrollElement?(r=o.scrollElement,c=r[a]()):r=l("html, body").firstScrollable(),o.beforeScroll.call(r,o),n="number"==typeof t?t:e||l(o.scrollTarget)[i]()&&l(o.scrollTarget)[i]()[o.direction]||0,f[a]=n+c+o.offset,s=o.speed,"auto"===s&&(s=f[a]||r.scrollTop(),s/=o.autoCoefficent),h={duration:s,easing:o.easing,complete:function(){o.afterScroll.call(o.link,o)}},o.step&&(h.step=o.step),r.length?r.stop().animate(f,h):o.afterScroll.call(o.link,o)},l.smoothScroll.version=e,l.smoothScroll.filterPath=function(l){return l.replace(/^\//,"").replace(/(index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},l.fn.smoothScroll.defaults=o})(jQuery);
\ No newline at end of file
diff --git a/package.json b/package.json
index 3ff6cc9..f362263 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "smooth-scroll",
- "version": "1.4.10",
+ "version": "1.4.11",
"scripts": {
"test": "./node_modules/.bin/grunt"
},
@@ -13,5 +13,6 @@
"grunt-shell": "~0.2",
"grunt-version": "~0.1.1",
"grunt-contrib-watch": "~0.3.1"
- }
+ },
+ "readmeFilename": "readme.md"
}
diff --git a/readme.md b/readme.md
index 419425d..5fe4138 100644
--- a/readme.md
+++ b/readme.md
@@ -40,7 +40,10 @@ The following options, shown with their default values, are available for both `
speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2
+ autoCoefficent: 2,
+
+ // $.fn.smoothScroll only: whether to prevent the default click action
+ preventDefault: true
}
```
diff --git a/smooth-scroll.jquery.json b/smooth-scroll.jquery.json
index 873404e..c52eac0 100644
--- a/smooth-scroll.jquery.json
+++ b/smooth-scroll.jquery.json
@@ -1,6 +1,6 @@
{
"name": "smooth-scroll",
- "version": "1.4.10",
+ "version": "1.4.11",
"title": "Smooth Scroll",
"description": "Easy implementation of smooth scrolling for same-page links",
"author": {
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index f3ab32d..9b89395 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -1,6 +1,6 @@
(function($) {
-var version = '1.4.10',
+var version = '1.4.11',
defaults = {
exclude: [],
excludeWithin:[],
@@ -27,7 +27,10 @@ var version = '1.4.10',
speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2
+ autoCoefficent: 2,
+
+ // $.fn.smoothScroll only: whether to prevent the default click action
+ preventDefault: true
},
getScrollable = function(opts) {
@@ -119,7 +122,10 @@ $.fn.extend({
}
if ( include ) {
- event.preventDefault();
+
+ if ( opts.preventDefault ) {
+ event.preventDefault();
+ }
$.extend( clickOpts, opts, {
scrollTarget: opts.scrollTarget || thisHash,
From 38a975a554c3459c5d93aec63839cd669d6d0e3f Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Tue, 16 Jul 2013 09:54:03 -0400
Subject: [PATCH 03/93] Add syntax highlighting for index.html
---
Gruntfile.js | 18 +++++++++----
index.html | 65 +++++++++++++++++++--------------------------
lib/tmpl/header.tpl | 24 +++++++++++++++++
package.json | 3 ++-
4 files changed, 66 insertions(+), 44 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 99e7e42..4999080 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -4,6 +4,18 @@ module.exports = function(grunt) {
// Because I'm lazy
var _ = grunt.util._;
+ var marked = require('marked');
+ // var hl = require('highlight').Highlight;
+ var hl = require('node-syntaxhighlighter');
+ marked.setOptions({
+ highlight: function(code, lang) {
+ lang = lang || 'javascript';
+ lang = hl.getLanguage(lang);
+
+ return hl.highlight(code, lang);
+ },
+ gfm: true
+ });
// Project configuration.
grunt.initConfig({
@@ -161,15 +173,11 @@ module.exports = function(grunt) {
});
grunt.registerTask('docs', 'Convert readme.md to html and concat with header and footer for index.html', function() {
- var marked = require('marked'),
- readme = grunt.file.read('readme.md'),
+ var readme = grunt.file.read('readme.md'),
head = grunt.template.process(grunt.file.read('lib/tmpl/header.tpl')),
foot = grunt.file.read('lib/tmpl/footer.tpl'),
doc = marked(readme);
- marked.setOptions({
- gfm: true
- });
grunt.file.write('index.html', head + doc + foot);
});
diff --git a/index.html b/index.html
index 05a3330..54aced3 100644
--- a/index.html
+++ b/index.html
@@ -32,6 +32,30 @@
code {
font-family: Monaco, Courier, monospace;
}
+ .comment,
+ .comments {
+ color: #aaa;
+ }
+ .keyword {
+ color: blue;
+ }
+ .string {
+ color: #090;
+ }
+ .number {
+ color: #099;
+ }
+
+ td.gutter {
+ text-align: right;
+ padding-right: 3px;
+ padding-left: 3px;
+ background-color: #ddd;
+ color: #aaa;
+ }
+ td.code {
+ padding-left: 5px;
+ }
h1, h2, h3 {
font-weight: normal;
color: #141414;
@@ -64,32 +88,7 @@
$.fn.smoothScroll
Options
The following options, shown with their default values, are available for both $.fn.smoothScroll and $.smoothScroll:
-
{
- offset: 0,
-
- // one of 'top' or 'left'
- direction: 'top',
-
- // only use if you want to override default behavior
- scrollTarget: null,
-
- // fn(opts) function to be called before scrolling occurs.
- // `this` is the element(s) being scrolled
- beforeScroll: function() {},
-
- // fn(opts) function to be called after scrolling occurs.
- // `this` is the triggering element
- afterScroll: function() {},
- easing: 'swing',
- speed: 400,
-
- // coefficient for "auto" speed
- autoCoefficent: 2,
-
- // $.fn.smoothScroll only: whether to prevent the default click action
- preventDefault: true
-
-}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
offset: 0,
// one of 'top' or 'left'
direction: 'top',
// only use if you want to override default behavior
scrollTarget: null,
// fn(opts) function to be called before scrolling occurs.
// `this` is the element(s) being scrolled
beforeScroll: function() {},
// fn(opts) function to be called after scrolling occurs.
// `this` is the triggering element
afterScroll: function() {},
easing: 'swing',
speed: 400,
// coefficient for "auto" speed
autoCoefficent: 2,
// $.fn.smoothScroll only: whether to prevent the default click action
preventDefault: true
}
The options object for $.fn.smoothScroll can take two additional properties:
exclude and excludeWithin. The value for both of these is an array of
selectors, DOM elements or jQuery objects. Default value for both is an
@@ -101,13 +100,7 @@
$.smoothScroll
document.body)
Doesn't automatically fire, so you need to bind it to some other user
interaction. For example:
p1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -48,7 +50,7 @@
Smooth Scroll jQuery Plugin with Back Button Support