jquery-smooth-scroll-rails 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/README.md +22 -2
- data/app/assets/javascripts/jquery-easing.js +222 -0
- data/app/assets/javascripts/jquery-smooth-scroll.js +267 -0
- data/lib/{jquey-smooth-scroll-rails.rb → jquery-smooth-scroll-rails.rb} +1 -1
- data/lib/jquery-smooth-scroll-rails/version.rb +3 -0
- metadata +18 -22
- data/lib/jquey-smooth-scroll-rails/version.rb +0 -3
- data/vendor/assets/javascripts/jquery.easing.js.coffee +0 -223
- data/vendor/assets/javascripts/jquery.smoothScroll.js.coffee +0 -148
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dfefec1e7d7aada47a298565e019b7e28f671ebe
|
4
|
+
data.tar.gz: ad6db3084d690982799b0bf94cb897801515cea7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b8cf622f038c987402a7293725fe949c8fe9ce14ea69fd1b57368e1f53c3d571838521b6669b9255c229ff6a213a861dcb113bc4e47d4f867a549bdc804ef0f
|
7
|
+
data.tar.gz: cdcf5c9cd9a8cda70ec150125c7560f5d6eff10223c42daf3917e1ec6447faa1a998a23f2f29e27313a20934887c0c51535d35a6b060505670320b6a8e973f3d
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,30 @@
|
|
1
1
|
## Installation
|
2
2
|
|
3
|
-
|
3
|
+
Rails programmer will have [jquery-smooth-scroll plugin](https://github.com/kswedberg/jquery-smooth-scroll) in asset pipeline when using this little shiny thang. Bling you scrolling!
|
4
|
+
|
5
|
+
There is no gem of this version bumping fork yet.
|
6
|
+
|
7
|
+
### Rails 4
|
8
|
+
|
9
|
+
Add this to your project's `Gemfile`:
|
4
10
|
|
5
11
|
```ruby
|
6
12
|
group :assets do
|
7
|
-
gem 'smooth-scroll-rails'
|
13
|
+
#gem 'jquery-smooth-scroll-rails'
|
14
|
+
gem 'jquery-smooth-scroll-rails', :git => 'git@github.com:gretel/jquery-smooth-scroll-rails.git'
|
8
15
|
end
|
9
16
|
```
|
10
17
|
|
18
|
+
Add this to `application.js`, possibly at `app/assets/javascripts/application.js`:
|
19
|
+
|
20
|
+
//= require jquery-smooth-scroll
|
21
|
+
|
22
|
+
For production you might need to [re-precompile](http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets) assets:
|
23
|
+
|
24
|
+
RAILS_ENV=production bundle exec rake assets:precompile
|
25
|
+
|
26
|
+
The actual usage is [explained here](https://github.com/kswedberg/jquery-smooth-scroll/blob/master/readme.md).
|
27
|
+
|
28
|
+
### Rails 3
|
29
|
+
|
30
|
+
Dunno if it works, sorry. Please report any issues.
|
@@ -0,0 +1,222 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3
|
+
*
|
4
|
+
* Uses the built in easing capabilities added In jQuery 1.1
|
5
|
+
* to offer multiple easing options
|
6
|
+
*
|
7
|
+
* TERMS OF USE - jQuery Easing
|
8
|
+
*
|
9
|
+
* Open source under the BSD License.
|
10
|
+
*
|
11
|
+
* Copyright © 2008 George McGinley Smith
|
12
|
+
* All rights reserved.
|
13
|
+
*
|
14
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
15
|
+
* are permitted provided that the following conditions are met:
|
16
|
+
*
|
17
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
18
|
+
* conditions and the following disclaimer.
|
19
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
20
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
21
|
+
* provided with the distribution.
|
22
|
+
*
|
23
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
24
|
+
* or promote products derived from this software without specific prior written permission.
|
25
|
+
*
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
|
38
|
+
// t: current time, b: begInnIng value, c: change In value, d: duration
|
39
|
+
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
40
|
+
|
41
|
+
jQuery.extend(jQuery.easing, {
|
42
|
+
def: 'easeOutQuad',
|
43
|
+
swing: function(x, t, b, c, d) {
|
44
|
+
//alert(jQuery.easing.default);
|
45
|
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
46
|
+
},
|
47
|
+
easeInQuad: function(x, t, b, c, d) {
|
48
|
+
return c * (t /= d) * t + b;
|
49
|
+
},
|
50
|
+
easeOutQuad: function(x, t, b, c, d) {
|
51
|
+
return -c * (t /= d) * (t - 2) + b;
|
52
|
+
},
|
53
|
+
easeInOutQuad: function(x, t, b, c, d) {
|
54
|
+
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
|
55
|
+
return -c / 2 * ((--t) * (t - 2) - 1) + b;
|
56
|
+
},
|
57
|
+
easeInCubic: function(x, t, b, c, d) {
|
58
|
+
return c * (t /= d) * t * t + b;
|
59
|
+
},
|
60
|
+
easeOutCubic: function(x, t, b, c, d) {
|
61
|
+
return c * ((t = t / d - 1) * t * t + 1) + b;
|
62
|
+
},
|
63
|
+
easeInOutCubic: function(x, t, b, c, d) {
|
64
|
+
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
|
65
|
+
return c / 2 * ((t -= 2) * t * t + 2) + b;
|
66
|
+
},
|
67
|
+
easeInQuart: function(x, t, b, c, d) {
|
68
|
+
return c * (t /= d) * t * t * t + b;
|
69
|
+
},
|
70
|
+
easeOutQuart: function(x, t, b, c, d) {
|
71
|
+
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
|
72
|
+
},
|
73
|
+
easeInOutQuart: function(x, t, b, c, d) {
|
74
|
+
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
|
75
|
+
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
|
76
|
+
},
|
77
|
+
easeInQuint: function(x, t, b, c, d) {
|
78
|
+
return c * (t /= d) * t * t * t * t + b;
|
79
|
+
},
|
80
|
+
easeOutQuint: function(x, t, b, c, d) {
|
81
|
+
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
|
82
|
+
},
|
83
|
+
easeInOutQuint: function(x, t, b, c, d) {
|
84
|
+
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
|
85
|
+
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
|
86
|
+
},
|
87
|
+
easeInSine: function(x, t, b, c, d) {
|
88
|
+
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
|
89
|
+
},
|
90
|
+
easeOutSine: function(x, t, b, c, d) {
|
91
|
+
return c * Math.sin(t / d * (Math.PI / 2)) + b;
|
92
|
+
},
|
93
|
+
easeInOutSine: function(x, t, b, c, d) {
|
94
|
+
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
|
95
|
+
},
|
96
|
+
easeInExpo: function(x, t, b, c, d) {
|
97
|
+
return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
|
98
|
+
},
|
99
|
+
easeOutExpo: function(x, t, b, c, d) {
|
100
|
+
return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
|
101
|
+
},
|
102
|
+
easeInOutExpo: function(x, t, b, c, d) {
|
103
|
+
if (t == 0) return b;
|
104
|
+
if (t == d) return b + c;
|
105
|
+
if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
|
106
|
+
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
107
|
+
},
|
108
|
+
easeInCirc: function(x, t, b, c, d) {
|
109
|
+
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
|
110
|
+
},
|
111
|
+
easeOutCirc: function(x, t, b, c, d) {
|
112
|
+
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
|
113
|
+
},
|
114
|
+
easeInOutCirc: function(x, t, b, c, d) {
|
115
|
+
if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
|
116
|
+
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
|
117
|
+
},
|
118
|
+
easeInElastic: function(x, t, b, c, d) {
|
119
|
+
var s = 1.70158;
|
120
|
+
var p = 0;
|
121
|
+
var a = c;
|
122
|
+
if (t == 0) return b;
|
123
|
+
if ((t /= d) == 1) return b + c;
|
124
|
+
if (!p) p = d * .3;
|
125
|
+
if (a < Math.abs(c)) {
|
126
|
+
a = c;
|
127
|
+
var s = p / 4;
|
128
|
+
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
|
129
|
+
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
130
|
+
},
|
131
|
+
easeOutElastic: function(x, t, b, c, d) {
|
132
|
+
var s = 1.70158;
|
133
|
+
var p = 0;
|
134
|
+
var a = c;
|
135
|
+
if (t == 0) return b;
|
136
|
+
if ((t /= d) == 1) return b + c;
|
137
|
+
if (!p) p = d * .3;
|
138
|
+
if (a < Math.abs(c)) {
|
139
|
+
a = c;
|
140
|
+
var s = p / 4;
|
141
|
+
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
|
142
|
+
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
|
143
|
+
},
|
144
|
+
easeInOutElastic: function(x, t, b, c, d) {
|
145
|
+
var s = 1.70158;
|
146
|
+
var p = 0;
|
147
|
+
var a = c;
|
148
|
+
if (t == 0) return b;
|
149
|
+
if ((t /= d / 2) == 2) return b + c;
|
150
|
+
if (!p) p = d * (.3 * 1.5);
|
151
|
+
if (a < Math.abs(c)) {
|
152
|
+
a = c;
|
153
|
+
var s = p / 4;
|
154
|
+
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
|
155
|
+
if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
156
|
+
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
|
157
|
+
},
|
158
|
+
easeInBack: function(x, t, b, c, d, s) {
|
159
|
+
if (s == undefined) s = 1.70158;
|
160
|
+
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
161
|
+
},
|
162
|
+
easeOutBack: function(x, t, b, c, d, s) {
|
163
|
+
if (s == undefined) s = 1.70158;
|
164
|
+
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
165
|
+
},
|
166
|
+
easeInOutBack: function(x, t, b, c, d, s) {
|
167
|
+
if (s == undefined) s = 1.70158;
|
168
|
+
if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
169
|
+
return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
|
170
|
+
},
|
171
|
+
easeInBounce: function(x, t, b, c, d) {
|
172
|
+
return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
|
173
|
+
},
|
174
|
+
easeOutBounce: function(x, t, b, c, d) {
|
175
|
+
if ((t /= d) < (1 / 2.75)) {
|
176
|
+
return c * (7.5625 * t * t) + b;
|
177
|
+
} else if (t < (2 / 2.75)) {
|
178
|
+
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
|
179
|
+
} else if (t < (2.5 / 2.75)) {
|
180
|
+
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
|
181
|
+
} else {
|
182
|
+
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
|
183
|
+
}
|
184
|
+
},
|
185
|
+
easeInOutBounce: function(x, t, b, c, d) {
|
186
|
+
if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
|
187
|
+
return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
|
188
|
+
}
|
189
|
+
});
|
190
|
+
|
191
|
+
/*
|
192
|
+
*
|
193
|
+
* TERMS OF USE - EASING EQUATIONS
|
194
|
+
*
|
195
|
+
* Open source under the BSD License.
|
196
|
+
*
|
197
|
+
* Copyright © 2001 Robert Penner
|
198
|
+
* All rights reserved.
|
199
|
+
*
|
200
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
201
|
+
* are permitted provided that the following conditions are met:
|
202
|
+
*
|
203
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
204
|
+
* conditions and the following disclaimer.
|
205
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
206
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
207
|
+
* provided with the distribution.
|
208
|
+
*
|
209
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
210
|
+
* or promote products derived from this software without specific prior written permission.
|
211
|
+
*
|
212
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
213
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
214
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
215
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
216
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
217
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
218
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
219
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
220
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
221
|
+
*
|
222
|
+
*/
|
@@ -0,0 +1,267 @@
|
|
1
|
+
/*!
|
2
|
+
* Smooth Scroll - v1.4.13 - 2013-11-02
|
3
|
+
* https://github.com/kswedberg/jquery-smooth-scroll
|
4
|
+
* Copyright (c) 2013 Karl Swedberg
|
5
|
+
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function($) {
|
9
|
+
var version = '1.4.13',
|
10
|
+
optionOverrides = {},
|
11
|
+
defaults = {
|
12
|
+
exclude: [],
|
13
|
+
excludeWithin: [],
|
14
|
+
offset: 0,
|
15
|
+
|
16
|
+
// one of 'top' or 'left'
|
17
|
+
direction: 'top',
|
18
|
+
|
19
|
+
// jQuery set of elements you wish to scroll (for $.smoothScroll).
|
20
|
+
// if null (default), $('html, body').firstScrollable() is used.
|
21
|
+
scrollElement: null,
|
22
|
+
|
23
|
+
// only use if you want to override default behavior
|
24
|
+
scrollTarget: null,
|
25
|
+
|
26
|
+
// fn(opts) function to be called before scrolling occurs.
|
27
|
+
// `this` is the element(s) being scrolled
|
28
|
+
beforeScroll: function() {},
|
29
|
+
|
30
|
+
// fn(opts) function to be called after scrolling occurs.
|
31
|
+
// `this` is the triggering element
|
32
|
+
afterScroll: function() {},
|
33
|
+
easing: 'swing',
|
34
|
+
speed: 400,
|
35
|
+
|
36
|
+
// coefficient for "auto" speed
|
37
|
+
autoCoefficent: 2,
|
38
|
+
|
39
|
+
// $.fn.smoothScroll only: whether to prevent the default click action
|
40
|
+
preventDefault: true
|
41
|
+
},
|
42
|
+
|
43
|
+
getScrollable = function(opts) {
|
44
|
+
var scrollable = [],
|
45
|
+
scrolled = false,
|
46
|
+
dir = opts.dir && opts.dir == 'left' ? 'scrollLeft' : 'scrollTop';
|
47
|
+
|
48
|
+
this.each(function() {
|
49
|
+
|
50
|
+
if (this == document || this == window) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
var el = $(this);
|
54
|
+
if (el[dir]() > 0) {
|
55
|
+
scrollable.push(this);
|
56
|
+
} else {
|
57
|
+
// if scroll(Top|Left) === 0, nudge the element 1px and see if it moves
|
58
|
+
el[dir](1);
|
59
|
+
scrolled = el[dir]() > 0;
|
60
|
+
if (scrolled) {
|
61
|
+
scrollable.push(this);
|
62
|
+
}
|
63
|
+
// then put it back, of course
|
64
|
+
el[dir](0);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
// If no scrollable elements, fall back to <body>,
|
69
|
+
// if it's in the jQuery collection
|
70
|
+
// (doing this because Safari sets scrollTop async,
|
71
|
+
// so can't set it to 1 and immediately get the value.)
|
72
|
+
if (!scrollable.length) {
|
73
|
+
this.each(function(index) {
|
74
|
+
if (this.nodeName === 'BODY') {
|
75
|
+
scrollable = [this];
|
76
|
+
}
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
// Use the first scrollable element if we're calling firstScrollable()
|
81
|
+
if (opts.el === 'first' && scrollable.length > 1) {
|
82
|
+
scrollable = [scrollable[0]];
|
83
|
+
}
|
84
|
+
|
85
|
+
return scrollable;
|
86
|
+
},
|
87
|
+
isTouch = 'ontouchend' in document;
|
88
|
+
|
89
|
+
$.fn.extend({
|
90
|
+
scrollable: function(dir) {
|
91
|
+
var scrl = getScrollable.call(this, {
|
92
|
+
dir: dir
|
93
|
+
});
|
94
|
+
return this.pushStack(scrl);
|
95
|
+
},
|
96
|
+
firstScrollable: function(dir) {
|
97
|
+
var scrl = getScrollable.call(this, {
|
98
|
+
el: 'first',
|
99
|
+
dir: dir
|
100
|
+
});
|
101
|
+
return this.pushStack(scrl);
|
102
|
+
},
|
103
|
+
|
104
|
+
smoothScroll: function(options, extra) {
|
105
|
+
options = options || {};
|
106
|
+
|
107
|
+
if (options === 'options') {
|
108
|
+
if (!extra) {
|
109
|
+
return this.first().data('ssOpts');
|
110
|
+
}
|
111
|
+
return this.each(function() {
|
112
|
+
var $this = $(this),
|
113
|
+
opts = $.extend($this.data('ssOpts') || {}, extra);
|
114
|
+
|
115
|
+
$(this).data('ssOpts', opts);
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
var opts = $.extend({}, $.fn.smoothScroll.defaults, options),
|
120
|
+
locationPath = $.smoothScroll.filterPath(location.pathname);
|
121
|
+
|
122
|
+
this
|
123
|
+
.unbind('click.smoothscroll')
|
124
|
+
.bind('click.smoothscroll', function(event) {
|
125
|
+
var link = this,
|
126
|
+
$link = $(this),
|
127
|
+
thisOpts = $.extend({}, opts, $link.data('ssOpts') || {}),
|
128
|
+
exclude = opts.exclude,
|
129
|
+
excludeWithin = thisOpts.excludeWithin,
|
130
|
+
elCounter = 0,
|
131
|
+
ewlCounter = 0,
|
132
|
+
include = true,
|
133
|
+
clickOpts = {},
|
134
|
+
hostMatch = ((location.hostname === link.hostname) || !link.hostname),
|
135
|
+
pathMatch = thisOpts.scrollTarget || ($.smoothScroll.filterPath(link.pathname) || locationPath) === locationPath,
|
136
|
+
thisHash = escapeSelector(link.hash);
|
137
|
+
|
138
|
+
if (!thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash)) {
|
139
|
+
include = false;
|
140
|
+
} else {
|
141
|
+
while (include && elCounter < exclude.length) {
|
142
|
+
if ($link.is(escapeSelector(exclude[elCounter++]))) {
|
143
|
+
include = false;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
while (include && ewlCounter < excludeWithin.length) {
|
147
|
+
if ($link.closest(excludeWithin[ewlCounter++]).length) {
|
148
|
+
include = false;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
if (include) {
|
154
|
+
|
155
|
+
if (thisOpts.preventDefault) {
|
156
|
+
event.preventDefault();
|
157
|
+
}
|
158
|
+
|
159
|
+
$.extend(clickOpts, thisOpts, {
|
160
|
+
scrollTarget: thisOpts.scrollTarget || thisHash,
|
161
|
+
link: link
|
162
|
+
});
|
163
|
+
$.smoothScroll(clickOpts);
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
return this;
|
168
|
+
}
|
169
|
+
});
|
170
|
+
|
171
|
+
$.smoothScroll = function(options, px) {
|
172
|
+
if (options === 'options' && typeof px === 'object') {
|
173
|
+
return $.extend(optionOverrides, px);
|
174
|
+
}
|
175
|
+
var opts, $scroller, scrollTargetOffset, speed,
|
176
|
+
scrollerOffset = 0,
|
177
|
+
offPos = 'offset',
|
178
|
+
scrollDir = 'scrollTop',
|
179
|
+
aniProps = {},
|
180
|
+
aniOpts = {},
|
181
|
+
scrollprops = [];
|
182
|
+
|
183
|
+
if (typeof options === 'number') {
|
184
|
+
opts = $.extend({
|
185
|
+
link: null
|
186
|
+
}, $.fn.smoothScroll.defaults, optionOverrides);
|
187
|
+
scrollTargetOffset = options;
|
188
|
+
} else {
|
189
|
+
opts = $.extend({
|
190
|
+
link: null
|
191
|
+
}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
|
192
|
+
if (opts.scrollElement) {
|
193
|
+
offPos = 'position';
|
194
|
+
if (opts.scrollElement.css('position') == 'static') {
|
195
|
+
opts.scrollElement.css('position', 'relative');
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
scrollDir = opts.direction == 'left' ? 'scrollLeft' : scrollDir;
|
201
|
+
|
202
|
+
if (opts.scrollElement) {
|
203
|
+
$scroller = opts.scrollElement;
|
204
|
+
if (!(/^(?:HTML|BODY)$/).test($scroller[0].nodeName)) {
|
205
|
+
scrollerOffset = $scroller[scrollDir]();
|
206
|
+
}
|
207
|
+
} else {
|
208
|
+
$scroller = $('html, body').firstScrollable(opts.direction);
|
209
|
+
}
|
210
|
+
|
211
|
+
// beforeScroll callback function must fire before calculating offset
|
212
|
+
opts.beforeScroll.call($scroller, opts);
|
213
|
+
|
214
|
+
scrollTargetOffset = (typeof options === 'number') ? options :
|
215
|
+
px ||
|
216
|
+
($(opts.scrollTarget)[offPos]() &&
|
217
|
+
$(opts.scrollTarget)[offPos]()[opts.direction]) ||
|
218
|
+
0;
|
219
|
+
|
220
|
+
aniProps[scrollDir] = scrollTargetOffset + scrollerOffset + opts.offset;
|
221
|
+
speed = opts.speed;
|
222
|
+
|
223
|
+
// automatically calculate the speed of the scroll based on distance / coefficient
|
224
|
+
if (speed === 'auto') {
|
225
|
+
|
226
|
+
// if aniProps[scrollDir] == 0 then we'll use scrollTop() value instead
|
227
|
+
speed = aniProps[scrollDir] || $scroller.scrollTop();
|
228
|
+
|
229
|
+
// divide the speed by the coefficient
|
230
|
+
speed = speed / opts.autoCoefficent;
|
231
|
+
}
|
232
|
+
|
233
|
+
aniOpts = {
|
234
|
+
duration: speed,
|
235
|
+
easing: opts.easing,
|
236
|
+
complete: function() {
|
237
|
+
opts.afterScroll.call(opts.link, opts);
|
238
|
+
}
|
239
|
+
};
|
240
|
+
|
241
|
+
if (opts.step) {
|
242
|
+
aniOpts.step = opts.step;
|
243
|
+
}
|
244
|
+
|
245
|
+
if ($scroller.length) {
|
246
|
+
$scroller.stop().animate(aniProps, aniOpts);
|
247
|
+
} else {
|
248
|
+
opts.afterScroll.call(opts.link, opts);
|
249
|
+
}
|
250
|
+
};
|
251
|
+
|
252
|
+
$.smoothScroll.version = version;
|
253
|
+
$.smoothScroll.filterPath = function(string) {
|
254
|
+
return string
|
255
|
+
.replace(/^\//, '')
|
256
|
+
.replace(/(?:index|default).[a-zA-Z]{3,4}$/, '')
|
257
|
+
.replace(/\/$/, '');
|
258
|
+
};
|
259
|
+
|
260
|
+
// default options
|
261
|
+
$.fn.smoothScroll.defaults = defaults;
|
262
|
+
|
263
|
+
function escapeSelector(str) {
|
264
|
+
return str.replace(/(:|\.)/g, '\\$1');
|
265
|
+
}
|
266
|
+
|
267
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,68 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-smooth-scroll-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- machida
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '4.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
description:
|
26
|
+
version: '4.0'
|
27
|
+
description: Automatically make same-page links scroll smoothly
|
31
28
|
email:
|
32
29
|
- machida@fjord.jp
|
33
30
|
executables: []
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- lib/jquey-smooth-scroll-rails/version.rb
|
38
|
-
- lib/jquey-smooth-scroll-rails.rb
|
39
|
-
- vendor/assets/javascripts/jquery.easing.js.coffee
|
40
|
-
- vendor/assets/javascripts/jquery.smoothScroll.js.coffee
|
41
34
|
- MIT-LICENSE
|
42
35
|
- README.md
|
43
|
-
|
36
|
+
- app/assets/javascripts/jquery-easing.js
|
37
|
+
- app/assets/javascripts/jquery-smooth-scroll.js
|
38
|
+
- lib/jquery-smooth-scroll-rails.rb
|
39
|
+
- lib/jquery-smooth-scroll-rails/version.rb
|
40
|
+
homepage: https://github.com/machida/jquery-smooth-scroll-rails
|
44
41
|
licenses: []
|
42
|
+
metadata: {}
|
45
43
|
post_install_message:
|
46
44
|
rdoc_options: []
|
47
45
|
require_paths:
|
48
46
|
- lib
|
49
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
48
|
requirements:
|
52
|
-
- -
|
49
|
+
- - ">="
|
53
50
|
- !ruby/object:Gem::Version
|
54
51
|
version: '0'
|
55
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
53
|
requirements:
|
58
|
-
- -
|
54
|
+
- - ">="
|
59
55
|
- !ruby/object:Gem::Version
|
60
56
|
version: '0'
|
61
57
|
requirements: []
|
62
58
|
rubyforge_project:
|
63
|
-
rubygems_version:
|
59
|
+
rubygems_version: 2.2.2
|
64
60
|
signing_key:
|
65
|
-
specification_version:
|
66
|
-
summary:
|
61
|
+
specification_version: 4
|
62
|
+
summary: jquery-smooth-scroll for rails
|
67
63
|
test_files: []
|
68
64
|
has_rdoc:
|
@@ -1,223 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3
|
-
# *
|
4
|
-
# * Uses the built in easing capabilities added In jQuery 1.1
|
5
|
-
# * to offer multiple easing options
|
6
|
-
# *
|
7
|
-
# * TERMS OF USE - jQuery Easing
|
8
|
-
# *
|
9
|
-
# * Open source under the BSD License.
|
10
|
-
# *
|
11
|
-
# * Copyright c 2008 George McGinley Smith
|
12
|
-
# * All rights reserved.
|
13
|
-
# *
|
14
|
-
# * Redistribution and use in source and binary forms, with or without modification,
|
15
|
-
# * are permitted provided that the following conditions are met:
|
16
|
-
# *
|
17
|
-
# * Redistributions of source code must retain the above copyright notice, this list of
|
18
|
-
# * conditions and the following disclaimer.
|
19
|
-
# * Redistributions in binary form must reproduce the above copyright notice, this list
|
20
|
-
# * of conditions and the following disclaimer in the documentation and/or other materials
|
21
|
-
# * provided with the distribution.
|
22
|
-
# *
|
23
|
-
# * Neither the name of the author nor the names of contributors may be used to endorse
|
24
|
-
# * or promote products derived from this software without specific prior written permission.
|
25
|
-
# *
|
26
|
-
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27
|
-
# * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28
|
-
# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29
|
-
# * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
-
# * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31
|
-
# * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32
|
-
# * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33
|
-
# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34
|
-
# * OF THE POSSIBILITY OF SUCH DAMAGE.
|
35
|
-
# *
|
36
|
-
#
|
37
|
-
|
38
|
-
# t: current time, b: begInnIng value, c: change In value, d: duration
|
39
|
-
jQuery.easing["jswing"] = jQuery.easing["swing"]
|
40
|
-
jQuery.extend jQuery.easing,
|
41
|
-
def: "easeOutQuad"
|
42
|
-
swing: (x, t, b, c, d) ->
|
43
|
-
|
44
|
-
#alert(jQuery.easing.default);
|
45
|
-
jQuery.easing[jQuery.easing.def] x, t, b, c, d
|
46
|
-
|
47
|
-
easeInQuad: (x, t, b, c, d) ->
|
48
|
-
c * (t /= d) * t + b
|
49
|
-
|
50
|
-
easeOutQuad: (x, t, b, c, d) ->
|
51
|
-
-c * (t /= d) * (t - 2) + b
|
52
|
-
|
53
|
-
easeInOutQuad: (x, t, b, c, d) ->
|
54
|
-
return c / 2 * t * t + b if (t /= d / 2) < 1
|
55
|
-
-c / 2 * ((--t) * (t - 2) - 1) + b
|
56
|
-
|
57
|
-
easeInCubic: (x, t, b, c, d) ->
|
58
|
-
c * (t /= d) * t * t + b
|
59
|
-
|
60
|
-
easeOutCubic: (x, t, b, c, d) ->
|
61
|
-
c * ((t = t / d - 1) * t * t + 1) + b
|
62
|
-
|
63
|
-
easeInOutCubic: (x, t, b, c, d) ->
|
64
|
-
return c / 2 * t * t * t + b if (t /= d / 2) < 1
|
65
|
-
c / 2 * ((t -= 2) * t * t + 2) + b
|
66
|
-
|
67
|
-
easeInQuart: (x, t, b, c, d) ->
|
68
|
-
c * (t /= d) * t * t * t + b
|
69
|
-
|
70
|
-
easeOutQuart: (x, t, b, c, d) ->
|
71
|
-
-c * ((t = t / d - 1) * t * t * t - 1) + b
|
72
|
-
|
73
|
-
easeInOutQuart: (x, t, b, c, d) ->
|
74
|
-
return c / 2 * t * t * t * t + b if (t /= d / 2) < 1
|
75
|
-
-c / 2 * ((t -= 2) * t * t * t - 2) + b
|
76
|
-
|
77
|
-
easeInQuint: (x, t, b, c, d) ->
|
78
|
-
c * (t /= d) * t * t * t * t + b
|
79
|
-
|
80
|
-
easeOutQuint: (x, t, b, c, d) ->
|
81
|
-
c * ((t = t / d - 1) * t * t * t * t + 1) + b
|
82
|
-
|
83
|
-
easeInOutQuint: (x, t, b, c, d) ->
|
84
|
-
return c / 2 * t * t * t * t * t + b if (t /= d / 2) < 1
|
85
|
-
c / 2 * ((t -= 2) * t * t * t * t + 2) + b
|
86
|
-
|
87
|
-
easeInSine: (x, t, b, c, d) ->
|
88
|
-
-c * Math.cos(t / d * (Math.PI / 2)) + c + b
|
89
|
-
|
90
|
-
easeOutSine: (x, t, b, c, d) ->
|
91
|
-
c * Math.sin(t / d * (Math.PI / 2)) + b
|
92
|
-
|
93
|
-
easeInOutSine: (x, t, b, c, d) ->
|
94
|
-
-c / 2 * (Math.cos(Math.PI * t / d) - 1) + b
|
95
|
-
|
96
|
-
easeInExpo: (x, t, b, c, d) ->
|
97
|
-
(if (t is 0) then b else c * Math.pow(2, 10 * (t / d - 1)) + b)
|
98
|
-
|
99
|
-
easeOutExpo: (x, t, b, c, d) ->
|
100
|
-
(if (t is d) then b + c else c * (-Math.pow(2, -10 * t / d) + 1) + b)
|
101
|
-
|
102
|
-
easeInOutExpo: (x, t, b, c, d) ->
|
103
|
-
return b if t is 0
|
104
|
-
return b + c if t is d
|
105
|
-
return c / 2 * Math.pow(2, 10 * (t - 1)) + b if (t /= d / 2) < 1
|
106
|
-
c / 2 * (-Math.pow(2, -10 * --t) + 2) + b
|
107
|
-
|
108
|
-
easeInCirc: (x, t, b, c, d) ->
|
109
|
-
-c * (Math.sqrt(1 - (t /= d) * t) - 1) + b
|
110
|
-
|
111
|
-
easeOutCirc: (x, t, b, c, d) ->
|
112
|
-
c * Math.sqrt(1 - (t = t / d - 1) * t) + b
|
113
|
-
|
114
|
-
easeInOutCirc: (x, t, b, c, d) ->
|
115
|
-
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b if (t /= d / 2) < 1
|
116
|
-
c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b
|
117
|
-
|
118
|
-
easeInElastic: (x, t, b, c, d) ->
|
119
|
-
s = 1.70158
|
120
|
-
p = 0
|
121
|
-
a = c
|
122
|
-
return b if t is 0
|
123
|
-
return b + c if (t /= d) is 1
|
124
|
-
p = d * .3 unless p
|
125
|
-
if a < Math.abs(c)
|
126
|
-
a = c
|
127
|
-
s = p / 4
|
128
|
-
else
|
129
|
-
s = p / (2 * Math.PI) * Math.asin(c / a)
|
130
|
-
-(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b
|
131
|
-
|
132
|
-
easeOutElastic: (x, t, b, c, d) ->
|
133
|
-
s = 1.70158
|
134
|
-
p = 0
|
135
|
-
a = c
|
136
|
-
return b if t is 0
|
137
|
-
return b + c if (t /= d) is 1
|
138
|
-
p = d * .3 unless p
|
139
|
-
if a < Math.abs(c)
|
140
|
-
a = c
|
141
|
-
s = p / 4
|
142
|
-
else
|
143
|
-
s = p / (2 * Math.PI) * Math.asin(c / a)
|
144
|
-
a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b
|
145
|
-
|
146
|
-
easeInOutElastic: (x, t, b, c, d) ->
|
147
|
-
s = 1.70158
|
148
|
-
p = 0
|
149
|
-
a = c
|
150
|
-
return b if t is 0
|
151
|
-
return b + c if (t /= d / 2) is 2
|
152
|
-
p = d * (.3 * 1.5) unless p
|
153
|
-
if a < Math.abs(c)
|
154
|
-
a = c
|
155
|
-
s = p / 4
|
156
|
-
else
|
157
|
-
s = p / (2 * Math.PI) * Math.asin(c / a)
|
158
|
-
return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b if t < 1
|
159
|
-
a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b
|
160
|
-
|
161
|
-
easeInBack: (x, t, b, c, d, s) ->
|
162
|
-
s = 1.70158 if s is `undefined`
|
163
|
-
c * (t /= d) * t * ((s + 1) * t - s) + b
|
164
|
-
|
165
|
-
easeOutBack: (x, t, b, c, d, s) ->
|
166
|
-
s = 1.70158 if s is `undefined`
|
167
|
-
c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b
|
168
|
-
|
169
|
-
easeInOutBack: (x, t, b, c, d, s) ->
|
170
|
-
s = 1.70158 if s is `undefined`
|
171
|
-
return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b if (t /= d / 2) < 1
|
172
|
-
c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b
|
173
|
-
|
174
|
-
easeInBounce: (x, t, b, c, d) ->
|
175
|
-
c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b
|
176
|
-
|
177
|
-
easeOutBounce: (x, t, b, c, d) ->
|
178
|
-
if (t /= d) < (1 / 2.75)
|
179
|
-
c * (7.5625 * t * t) + b
|
180
|
-
else if t < (2 / 2.75)
|
181
|
-
c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b
|
182
|
-
else if t < (2.5 / 2.75)
|
183
|
-
c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b
|
184
|
-
else
|
185
|
-
c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b
|
186
|
-
|
187
|
-
easeInOutBounce: (x, t, b, c, d) ->
|
188
|
-
return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b if t < d / 2
|
189
|
-
jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b
|
190
|
-
|
191
|
-
|
192
|
-
#
|
193
|
-
# *
|
194
|
-
# * TERMS OF USE - EASING EQUATIONS
|
195
|
-
# *
|
196
|
-
# * Open source under the BSD License.
|
197
|
-
# *
|
198
|
-
# * Copyright c 2001 Robert Penner
|
199
|
-
# * All rights reserved.
|
200
|
-
# *
|
201
|
-
# * Redistribution and use in source and binary forms, with or without modification,
|
202
|
-
# * are permitted provided that the following conditions are met:
|
203
|
-
# *
|
204
|
-
# * Redistributions of source code must retain the above copyright notice, this list of
|
205
|
-
# * conditions and the following disclaimer.
|
206
|
-
# * Redistributions in binary form must reproduce the above copyright notice, this list
|
207
|
-
# * of conditions and the following disclaimer in the documentation and/or other materials
|
208
|
-
# * provided with the distribution.
|
209
|
-
# *
|
210
|
-
# * Neither the name of the author nor the names of contributors may be used to endorse
|
211
|
-
# * or promote products derived from this software without specific prior written permission.
|
212
|
-
# *
|
213
|
-
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
214
|
-
# * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
215
|
-
# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
216
|
-
# * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
217
|
-
# * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
218
|
-
# * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
219
|
-
# * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
220
|
-
# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
221
|
-
# * OF THE POSSIBILITY OF SUCH DAMAGE.
|
222
|
-
# *
|
223
|
-
#
|
@@ -1,148 +0,0 @@
|
|
1
|
-
###
|
2
|
-
jQuery SmoothScroll Plugin
|
3
|
-
Required: jQuery(http://jquery.com/)
|
4
|
-
License: MIT
|
5
|
-
Update: 2012/12/06
|
6
|
-
Version: 1.1
|
7
|
-
Original Author: yuu.creatorish
|
8
|
-
Customized: machida
|
9
|
-
URL: http://creatorish.com
|
10
|
-
PluginURL: http://creatorish.com/lab/5393
|
11
|
-
###
|
12
|
-
|
13
|
-
jQuery.fn.smoothScroll = (op) ->
|
14
|
-
clickHandler = (e) ->
|
15
|
-
e.preventDefault()
|
16
|
-
e.stopPropagation()
|
17
|
-
h = jQuery(this).attr("href")
|
18
|
-
t = jQuery(h)
|
19
|
-
t = d if t.length is 0
|
20
|
-
scrolling = true
|
21
|
-
if c
|
22
|
-
s.attr
|
23
|
-
st: c.scrollTop()
|
24
|
-
sl: c.scrollLeft()
|
25
|
-
|
26
|
-
else
|
27
|
-
s.attr
|
28
|
-
st: w.scrollTop()
|
29
|
-
sl: w.scrollLeft()
|
30
|
-
|
31
|
-
option.start s.attr("sl"), s.attr("st")
|
32
|
-
o = t.offset()
|
33
|
-
if c
|
34
|
-
o = t.position()
|
35
|
-
o.top = c.get(0).scrollHeight - c.innerHeight() if o.top > c.get(0).scrollHeight - c.innerHeight()
|
36
|
-
s.stop(true).animate
|
37
|
-
st: o.top
|
38
|
-
sl: o.left
|
39
|
-
,
|
40
|
-
duration: option.duration
|
41
|
-
easing: option.easing
|
42
|
-
step: stepHandler
|
43
|
-
complete: completeHandler
|
44
|
-
|
45
|
-
completeHandler = ->
|
46
|
-
scrolling = false
|
47
|
-
scroll @sl, @st
|
48
|
-
option.complete @sl, @st
|
49
|
-
stepHandler = ->
|
50
|
-
scroll @sl, @st
|
51
|
-
option.step @sl, @st
|
52
|
-
scroll = (x, y) ->
|
53
|
-
if c
|
54
|
-
c.scrollLeft x
|
55
|
-
c.scrollTop y
|
56
|
-
else
|
57
|
-
window.scrollTo x, y
|
58
|
-
stopQueue = ->
|
59
|
-
if scrolling
|
60
|
-
option.canceled s.attr("sl"), s.attr("st")
|
61
|
-
scrolling = false
|
62
|
-
s.stop true
|
63
|
-
scrollTo = (x, y) ->
|
64
|
-
scrolling = true
|
65
|
-
if c
|
66
|
-
s.attr
|
67
|
-
st: c.scrollTop()
|
68
|
-
sl: c.scrollLeft()
|
69
|
-
|
70
|
-
else
|
71
|
-
s.attr
|
72
|
-
st: w.scrollTop()
|
73
|
-
sl: w.scrollLeft()
|
74
|
-
|
75
|
-
option.start s.attr("sl"), s.attr("st")
|
76
|
-
o =
|
77
|
-
top: y
|
78
|
-
left: x
|
79
|
-
|
80
|
-
if c
|
81
|
-
o.top = c.get(0).scrollHeight - c.innerHeight() if o.top > c.get(0).scrollHeight - c.innerHeight()
|
82
|
-
o.left = c.get(0).scrollWidth - c.innerWidth() if o.left > c.get(0).scrollWidth - c.innerWidth()
|
83
|
-
else
|
84
|
-
o.top = document.body.scrollHeight - window.innerHeight if o.top > document.body.scrollHeight - window.innerHeight
|
85
|
-
o.left = document.body.scrollWidth - window.innerWidth if o.left > document.body.scrollWidth - window.innerWidth
|
86
|
-
s.stop(true).animate
|
87
|
-
st: o.top
|
88
|
-
sl: o.left
|
89
|
-
,
|
90
|
-
duration: option.duration
|
91
|
-
easing: option.easing
|
92
|
-
step: stepHandler
|
93
|
-
complete: completeHandler
|
94
|
-
|
95
|
-
scrollToElement = (selector) ->
|
96
|
-
o = jQuery(selector).offset()
|
97
|
-
o = jQuery(selector).position() if c
|
98
|
-
scrollTo o.left, o.top
|
99
|
-
option =
|
100
|
-
easing: "swing"
|
101
|
-
duration: 500
|
102
|
-
cancel: true
|
103
|
-
target: null
|
104
|
-
start: (x, y) ->
|
105
|
-
|
106
|
-
step: (x, y) ->
|
107
|
-
|
108
|
-
canceled: (x, y) ->
|
109
|
-
|
110
|
-
complete: (x, y) ->
|
111
|
-
|
112
|
-
jQuery.extend option, op
|
113
|
-
scrolling = false
|
114
|
-
w = jQuery(window)
|
115
|
-
d = jQuery(document.body)
|
116
|
-
s = jQuery(
|
117
|
-
st: 0
|
118
|
-
sl: 0
|
119
|
-
v: 0
|
120
|
-
)
|
121
|
-
c = undefined
|
122
|
-
if option.target
|
123
|
-
c = jQuery(option.target)
|
124
|
-
c.wrapInner "<div style='position: relative'></div>" unless c.children().length is 1
|
125
|
-
if option.cancel
|
126
|
-
if "ontouchend" of document
|
127
|
-
if c
|
128
|
-
c.unbind "touchstart", stopQueue
|
129
|
-
c.bind "touchstart", stopQueue
|
130
|
-
else
|
131
|
-
d.unbind "touchstart", stopQueue
|
132
|
-
d.bind "touchstart", stopQueue
|
133
|
-
else
|
134
|
-
if c
|
135
|
-
c.bind "DOMMouseScroll mousewheel", stopQueue
|
136
|
-
c.unbind "mousedown", stopQueue
|
137
|
-
c.bind "mousedown", stopQueue
|
138
|
-
else
|
139
|
-
w.bind "DOMMouseScroll mousewheel", stopQueue
|
140
|
-
d.unbind "mousedown", stopQueue
|
141
|
-
d.bind "mousedown", stopQueue
|
142
|
-
jQuery.each this, ->
|
143
|
-
jQuery(this).unbind "click", clickHandler
|
144
|
-
jQuery(this).bind "click", clickHandler
|
145
|
-
|
146
|
-
scroll: scrollTo
|
147
|
-
scrollToElement: scrollToElement
|
148
|
-
stop: stopQueue
|