infinitescrolling-rails 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/infinitescrolling-rails.gemspec +1 -1
- data/vendor/assets/javascripts/infinitescrolling.js +38 -24
- metadata +25 -10
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,37 +1,51 @@
|
|
1
1
|
(function($){
|
2
|
-
|
3
|
-
|
2
|
+
function IS(loadCallback, target) {
|
3
|
+
var my = {
|
4
|
+
loadCallback: loadCallback,
|
5
|
+
target : target,
|
6
|
+
marginThreshold: 20,
|
7
|
+
delay: 250,
|
8
|
+
hasScrolled: false,
|
4
9
|
|
5
|
-
|
10
|
+
callback: function(){
|
11
|
+
if (!my.hasScrolled){
|
12
|
+
my.hasScrolled = true;
|
13
|
+
setTimeout(my.checkScroll, my.delay);
|
14
|
+
}
|
15
|
+
},
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
},
|
17
|
+
checkScroll: function() {
|
18
|
+
my.hasScrolled = false;
|
19
|
+
if (my.lowEnough()) {
|
20
|
+
my.loadCallback();
|
21
|
+
}
|
22
|
+
},
|
15
23
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
lowEnough: function() {
|
25
|
+
if (this.target[0] === window || this.target[0] === document) {
|
26
|
+
var pageHeight = $(document).height();
|
27
|
+
var viewportHeight = $(window).height();
|
28
|
+
var scrollHeight = $(document).scrollTop();
|
29
|
+
return pageHeight - viewportHeight - scrollHeight < my.marginThreshold;
|
30
|
+
} else {
|
31
|
+
var pageHeight = $(this.target).find('[data-infinite-scrolling]').height();
|
32
|
+
var viewportHeight = $(this.target).height();
|
33
|
+
var scrollHeight = $(this.target).scrollTop();
|
34
|
+
return pageHeight - viewportHeight - scrollHeight < my.marginThreshold;
|
35
|
+
}
|
20
36
|
}
|
21
|
-
}
|
37
|
+
}
|
22
38
|
|
23
|
-
|
24
|
-
|
25
|
-
var viewportHeight = $(window).height();
|
26
|
-
var scrollHeight = $(document).scrollTop();
|
27
|
-
return pageHeight - viewportHeight - scrollHeight < my.marginThreshold;
|
39
|
+
IS.prototype.callback = function() {
|
40
|
+
my.callback();
|
28
41
|
}
|
29
42
|
};
|
30
43
|
|
31
44
|
$.fn.infiniteScrolling = function(loadCallback){
|
32
|
-
|
33
|
-
|
34
|
-
this.
|
45
|
+
var is = new IS(loadCallback, this);
|
46
|
+
|
47
|
+
this.on('scroll', is.callback);
|
48
|
+
this.on('resize', is.callback);
|
35
49
|
return this;
|
36
50
|
};
|
37
51
|
})(jQuery);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infinitescrolling-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>'
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>'
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: jquery-rails
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: bundler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '1.0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
47
62
|
description: This gem provides the infinite scrolling jQuery plugin for your Rails
|
48
63
|
3.1 application.
|
49
64
|
email:
|
@@ -76,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
91
|
version: '0'
|
77
92
|
segments:
|
78
93
|
- 0
|
79
|
-
hash:
|
94
|
+
hash: -210072818456481541
|
80
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
96
|
none: false
|
82
97
|
requirements:
|
@@ -85,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
100
|
version: 1.3.6
|
86
101
|
requirements: []
|
87
102
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
103
|
+
rubygems_version: 1.8.24
|
89
104
|
signing_key:
|
90
105
|
specification_version: 3
|
91
106
|
summary: Use the infinite scrolling jQuery plugin with Rails 3.1
|