jquery-smooth-scroll-rails 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 mahm
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ ## Installation
2
+
3
+ Add this to your `Gemfile`:
4
+
5
+ ```ruby
6
+ group :assets do
7
+ gem 'smooth-scroll-rails'
8
+ end
9
+ ```
10
+
@@ -0,0 +1,6 @@
1
+ require "jquey-smooth-scroll-rails/version"
2
+
3
+ module JquerySmoothScrollRails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module JqueySmoothScrollRails
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,223 @@
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
+ #
@@ -0,0 +1,148 @@
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
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-smooth-scroll-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - machida
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ description: SmoothScroll(A jQuery plugin that smooth scroll.) for rails.
31
+ email:
32
+ - machida@fjord.jp
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ 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
+ - MIT-LICENSE
42
+ - README.md
43
+ homepage: http://fjord.jp
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.24
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: jquey-smooth-scroll for rails
67
+ test_files: []
68
+ has_rdoc: