antiscroll_rails 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/antiscroll_rails.gemspec +25 -0
- data/lib/antiscroll_rails/version.rb +3 -0
- data/lib/antiscroll_rails.rb +8 -0
- data/vendor/javascripts/antiscroll.js +471 -0
- data/vendor/stylesheets/antiscroll.css +60 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 303bf65f95909bcf742d0453154c582665d22108
|
4
|
+
data.tar.gz: ee788cf6e34cf7c7049049e7a24d373d81317e8e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99e5d0d0aeb682e92c7da4c36a8be7954ae45d2ea6e616f88fcd6e52caba1840c826fb72c915e36a883fcef5730a003576f1ec3e88e1d6bcad5e716435d93d21
|
7
|
+
data.tar.gz: 3615acd8433598d4f2c5cf8094ca93be81bc5fb70f51c92757a266d2e042f7cbde9e3fdf392315cc0ff886e3d0816be33af50e6288c41d714e1ec9543742aabb
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Guy Israeli
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# AntiscrollRails
|
2
|
+
|
3
|
+
antiscroll.js for rails
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'antiscroll_rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install antiscroll_rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
add to manifests
|
22
|
+
|
23
|
+
//= require antiscroll
|
24
|
+
|
25
|
+
*= require antiscroll
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/[my-github-username]/antiscroll_rails/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'antiscroll_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "antiscroll_rails"
|
8
|
+
spec.version = AntiscrollRails::VERSION
|
9
|
+
spec.authors = ["Guy Israeli"]
|
10
|
+
spec.email = ["guy.israeli@gmail.com"]
|
11
|
+
spec.summary = %q{Antiscroll.js for Rails}
|
12
|
+
spec.description = %q{creating OS X Lion type scrollbars - Antiscroll, for Rails!}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "railties", ">= 3.1"
|
24
|
+
spec.add_dependency "jquery-mousewheel_rails", "~>3.1.11"
|
25
|
+
end
|
@@ -0,0 +1,471 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Augment jQuery prototype.
|
5
|
+
*/
|
6
|
+
|
7
|
+
$.fn.antiscroll = function (options) {
|
8
|
+
return this.each(function () {
|
9
|
+
if ($(this).data('antiscroll')) {
|
10
|
+
$(this).data('antiscroll').destroy();
|
11
|
+
}
|
12
|
+
|
13
|
+
$(this).data('antiscroll', new $.Antiscroll(this, options));
|
14
|
+
});
|
15
|
+
};
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Expose constructor.
|
19
|
+
*/
|
20
|
+
|
21
|
+
$.Antiscroll = Antiscroll;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Antiscroll pane constructor.
|
25
|
+
*
|
26
|
+
* @param {Element|jQuery} main pane
|
27
|
+
* @parma {Object} options
|
28
|
+
* @api public
|
29
|
+
*/
|
30
|
+
|
31
|
+
function Antiscroll (el, opts) {
|
32
|
+
this.el = $(el);
|
33
|
+
this.options = opts || {};
|
34
|
+
|
35
|
+
this.x = (false !== this.options.x) || this.options.forceHorizontal;
|
36
|
+
this.y = (false !== this.options.y) || this.options.forceVertical;
|
37
|
+
this.autoHide = false !== this.options.autoHide;
|
38
|
+
this.padding = undefined == this.options.padding ? 2 : this.options.padding;
|
39
|
+
|
40
|
+
this.inner = this.el.find('.antiscroll-inner');
|
41
|
+
this.inner.css({
|
42
|
+
'width': '+=' + (this.y ? scrollbarSize() : 0)
|
43
|
+
, 'height': '+=' + (this.x ? scrollbarSize() : 0)
|
44
|
+
});
|
45
|
+
|
46
|
+
this.refresh();
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* refresh scrollbars
|
51
|
+
*
|
52
|
+
* @api public
|
53
|
+
*/
|
54
|
+
|
55
|
+
Antiscroll.prototype.refresh = function() {
|
56
|
+
var needHScroll = this.inner.get(0).scrollWidth > this.el.width() + (this.y ? scrollbarSize() : 0),
|
57
|
+
needVScroll = this.inner.get(0).scrollHeight > this.el.height() + (this.x ? scrollbarSize() : 0);
|
58
|
+
|
59
|
+
if (this.x) {
|
60
|
+
if (!this.horizontal && needHScroll) {
|
61
|
+
this.horizontal = new Scrollbar.Horizontal(this);
|
62
|
+
} else if (this.horizontal && !needHScroll) {
|
63
|
+
this.horizontal.destroy();
|
64
|
+
this.horizontal = null;
|
65
|
+
} else if (this.horizontal) {
|
66
|
+
this.horizontal.update();
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
if (this.y) {
|
71
|
+
if (!this.vertical && needVScroll) {
|
72
|
+
this.vertical = new Scrollbar.Vertical(this);
|
73
|
+
} else if (this.vertical && !needVScroll) {
|
74
|
+
this.vertical.destroy();
|
75
|
+
this.vertical = null;
|
76
|
+
} else if (this.vertical) {
|
77
|
+
this.vertical.update();
|
78
|
+
}
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Cleans up.
|
84
|
+
*
|
85
|
+
* @return {Antiscroll} for chaining
|
86
|
+
* @api public
|
87
|
+
*/
|
88
|
+
|
89
|
+
Antiscroll.prototype.destroy = function () {
|
90
|
+
if (this.horizontal) {
|
91
|
+
this.horizontal.destroy();
|
92
|
+
this.horizontal = null
|
93
|
+
}
|
94
|
+
if (this.vertical) {
|
95
|
+
this.vertical.destroy();
|
96
|
+
this.vertical = null
|
97
|
+
}
|
98
|
+
return this;
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Rebuild Antiscroll.
|
103
|
+
*
|
104
|
+
* @return {Antiscroll} for chaining
|
105
|
+
* @api public
|
106
|
+
*/
|
107
|
+
|
108
|
+
Antiscroll.prototype.rebuild = function () {
|
109
|
+
this.destroy();
|
110
|
+
this.inner.attr('style', '');
|
111
|
+
Antiscroll.call(this, this.el, this.options);
|
112
|
+
return this;
|
113
|
+
};
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Scrollbar constructor.
|
117
|
+
*
|
118
|
+
* @param {Element|jQuery} element
|
119
|
+
* @api public
|
120
|
+
*/
|
121
|
+
|
122
|
+
function Scrollbar (pane) {
|
123
|
+
this.pane = pane;
|
124
|
+
this.pane.el.append(this.el);
|
125
|
+
this.innerEl = this.pane.inner.get(0);
|
126
|
+
|
127
|
+
this.dragging = false;
|
128
|
+
this.enter = false;
|
129
|
+
this.shown = false;
|
130
|
+
|
131
|
+
// hovering
|
132
|
+
this.pane.el.mouseenter($.proxy(this, 'mouseenter'));
|
133
|
+
this.pane.el.mouseleave($.proxy(this, 'mouseleave'));
|
134
|
+
|
135
|
+
// dragging
|
136
|
+
this.el.mousedown($.proxy(this, 'mousedown'));
|
137
|
+
|
138
|
+
// scrolling
|
139
|
+
this.innerPaneScrollListener = $.proxy(this, 'scroll');
|
140
|
+
this.pane.inner.scroll(this.innerPaneScrollListener);
|
141
|
+
|
142
|
+
// wheel -optional-
|
143
|
+
this.innerPaneMouseWheelListener = $.proxy(this, 'mousewheel');
|
144
|
+
this.pane.inner.bind('mousewheel', this.innerPaneMouseWheelListener);
|
145
|
+
|
146
|
+
// show
|
147
|
+
var initialDisplay = this.pane.options.initialDisplay;
|
148
|
+
|
149
|
+
if (initialDisplay !== false) {
|
150
|
+
this.show();
|
151
|
+
if (this.pane.autoHide) {
|
152
|
+
this.hiding = setTimeout($.proxy(this, 'hide'), parseInt(initialDisplay, 10) || 3000);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Cleans up.
|
159
|
+
*
|
160
|
+
* @return {Scrollbar} for chaining
|
161
|
+
* @api public
|
162
|
+
*/
|
163
|
+
|
164
|
+
Scrollbar.prototype.destroy = function () {
|
165
|
+
this.el.remove();
|
166
|
+
this.pane.inner.unbind('scroll', this.innerPaneScrollListener);
|
167
|
+
this.pane.inner.unbind('mousewheel', this.innerPaneMouseWheelListener);
|
168
|
+
return this;
|
169
|
+
};
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Called upon mouseenter.
|
173
|
+
*
|
174
|
+
* @api private
|
175
|
+
*/
|
176
|
+
|
177
|
+
Scrollbar.prototype.mouseenter = function () {
|
178
|
+
this.enter = true;
|
179
|
+
this.show();
|
180
|
+
};
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Called upon mouseleave.
|
184
|
+
*
|
185
|
+
* @api private
|
186
|
+
*/
|
187
|
+
|
188
|
+
Scrollbar.prototype.mouseleave = function () {
|
189
|
+
this.enter = false;
|
190
|
+
|
191
|
+
if (!this.dragging) {
|
192
|
+
if (this.pane.autoHide) {
|
193
|
+
this.hide();
|
194
|
+
}
|
195
|
+
}
|
196
|
+
};
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Called upon wrap scroll.
|
200
|
+
*
|
201
|
+
* @api private
|
202
|
+
*/
|
203
|
+
|
204
|
+
Scrollbar.prototype.scroll = function () {
|
205
|
+
if (!this.shown) {
|
206
|
+
this.show();
|
207
|
+
if (!this.enter && !this.dragging) {
|
208
|
+
if (this.pane.autoHide) {
|
209
|
+
this.hiding = setTimeout($.proxy(this, 'hide'), 1500);
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
this.update();
|
215
|
+
};
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Called upon scrollbar mousedown.
|
219
|
+
*
|
220
|
+
* @api private
|
221
|
+
*/
|
222
|
+
|
223
|
+
Scrollbar.prototype.mousedown = function (ev) {
|
224
|
+
ev.preventDefault();
|
225
|
+
|
226
|
+
this.dragging = true;
|
227
|
+
|
228
|
+
this.startPageY = ev.pageY - parseInt(this.el.css('top'), 10);
|
229
|
+
this.startPageX = ev.pageX - parseInt(this.el.css('left'), 10);
|
230
|
+
|
231
|
+
// prevent crazy selections on IE
|
232
|
+
this.el[0].ownerDocument.onselectstart = function () { return false; };
|
233
|
+
|
234
|
+
var pane = this.pane,
|
235
|
+
move = $.proxy(this, 'mousemove'),
|
236
|
+
self = this
|
237
|
+
|
238
|
+
$(this.el[0].ownerDocument)
|
239
|
+
.mousemove(move)
|
240
|
+
.mouseup(function () {
|
241
|
+
self.dragging = false;
|
242
|
+
this.onselectstart = null;
|
243
|
+
|
244
|
+
$(this).unbind('mousemove', move);
|
245
|
+
|
246
|
+
if (!self.enter) {
|
247
|
+
self.hide();
|
248
|
+
}
|
249
|
+
});
|
250
|
+
};
|
251
|
+
|
252
|
+
/**
|
253
|
+
* Show scrollbar.
|
254
|
+
*
|
255
|
+
* @api private
|
256
|
+
*/
|
257
|
+
|
258
|
+
Scrollbar.prototype.show = function (duration) {
|
259
|
+
if (!this.shown && this.update()) {
|
260
|
+
this.el.addClass('antiscroll-scrollbar-shown');
|
261
|
+
if (this.hiding) {
|
262
|
+
clearTimeout(this.hiding);
|
263
|
+
this.hiding = null;
|
264
|
+
}
|
265
|
+
this.shown = true;
|
266
|
+
}
|
267
|
+
};
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Hide scrollbar.
|
271
|
+
*
|
272
|
+
* @api private
|
273
|
+
*/
|
274
|
+
|
275
|
+
Scrollbar.prototype.hide = function () {
|
276
|
+
if (this.pane.autoHide !== false && this.shown) {
|
277
|
+
// check for dragging
|
278
|
+
this.el.removeClass('antiscroll-scrollbar-shown');
|
279
|
+
this.shown = false;
|
280
|
+
}
|
281
|
+
};
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Horizontal scrollbar constructor
|
285
|
+
*
|
286
|
+
* @api private
|
287
|
+
*/
|
288
|
+
|
289
|
+
Scrollbar.Horizontal = function (pane) {
|
290
|
+
this.el = $('<div class="antiscroll-scrollbar antiscroll-scrollbar-horizontal"/>', pane.el);
|
291
|
+
Scrollbar.call(this, pane);
|
292
|
+
};
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Inherits from Scrollbar.
|
296
|
+
*/
|
297
|
+
|
298
|
+
inherits(Scrollbar.Horizontal, Scrollbar);
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Updates size/position of scrollbar.
|
302
|
+
*
|
303
|
+
* @api private
|
304
|
+
*/
|
305
|
+
|
306
|
+
Scrollbar.Horizontal.prototype.update = function () {
|
307
|
+
var paneWidth = this.pane.el.width(),
|
308
|
+
trackWidth = paneWidth - this.pane.padding * 2,
|
309
|
+
innerEl = this.pane.inner.get(0)
|
310
|
+
|
311
|
+
this.el
|
312
|
+
.css('width', trackWidth * paneWidth / innerEl.scrollWidth)
|
313
|
+
.css('left', trackWidth * innerEl.scrollLeft / innerEl.scrollWidth);
|
314
|
+
|
315
|
+
return paneWidth < innerEl.scrollWidth;
|
316
|
+
};
|
317
|
+
|
318
|
+
/**
|
319
|
+
* Called upon drag.
|
320
|
+
*
|
321
|
+
* @api private
|
322
|
+
*/
|
323
|
+
|
324
|
+
Scrollbar.Horizontal.prototype.mousemove = function (ev) {
|
325
|
+
var trackWidth = this.pane.el.width() - this.pane.padding * 2,
|
326
|
+
pos = ev.pageX - this.startPageX,
|
327
|
+
barWidth = this.el.width(),
|
328
|
+
innerEl = this.pane.inner.get(0)
|
329
|
+
|
330
|
+
// minimum top is 0, maximum is the track height
|
331
|
+
var y = Math.min(Math.max(pos, 0), trackWidth - barWidth);
|
332
|
+
|
333
|
+
innerEl.scrollLeft = (innerEl.scrollWidth - this.pane.el.width())
|
334
|
+
* y / (trackWidth - barWidth);
|
335
|
+
};
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Called upon container mousewheel.
|
339
|
+
*
|
340
|
+
* @api private
|
341
|
+
*/
|
342
|
+
|
343
|
+
Scrollbar.Horizontal.prototype.mousewheel = function (ev, delta, x, y) {
|
344
|
+
if ((x < 0 && 0 == this.pane.inner.get(0).scrollLeft) ||
|
345
|
+
(x > 0 && (this.innerEl.scrollLeft + Math.ceil(this.pane.el.width())
|
346
|
+
== this.innerEl.scrollWidth))) {
|
347
|
+
ev.preventDefault();
|
348
|
+
return false;
|
349
|
+
}
|
350
|
+
};
|
351
|
+
|
352
|
+
/**
|
353
|
+
* Vertical scrollbar constructor
|
354
|
+
*
|
355
|
+
* @api private
|
356
|
+
*/
|
357
|
+
|
358
|
+
Scrollbar.Vertical = function (pane) {
|
359
|
+
this.el = $('<div class="antiscroll-scrollbar antiscroll-scrollbar-vertical"/>', pane.el);
|
360
|
+
Scrollbar.call(this, pane);
|
361
|
+
};
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Inherits from Scrollbar.
|
365
|
+
*/
|
366
|
+
|
367
|
+
inherits(Scrollbar.Vertical, Scrollbar);
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Updates size/position of scrollbar.
|
371
|
+
*
|
372
|
+
* @api private
|
373
|
+
*/
|
374
|
+
|
375
|
+
Scrollbar.Vertical.prototype.update = function () {
|
376
|
+
var paneHeight = this.pane.el.height(),
|
377
|
+
trackHeight = paneHeight - this.pane.padding * 2,
|
378
|
+
innerEl = this.innerEl;
|
379
|
+
|
380
|
+
var scrollbarHeight = trackHeight * paneHeight / innerEl.scrollHeight;
|
381
|
+
scrollbarHeight = scrollbarHeight < 20 ? 20 : scrollbarHeight;
|
382
|
+
|
383
|
+
var topPos = trackHeight * innerEl.scrollTop / innerEl.scrollHeight;
|
384
|
+
|
385
|
+
if((topPos + scrollbarHeight) > trackHeight) {
|
386
|
+
var diff = (topPos + scrollbarHeight) - trackHeight;
|
387
|
+
topPos = topPos - diff - 3;
|
388
|
+
}
|
389
|
+
|
390
|
+
this.el
|
391
|
+
.css('height', scrollbarHeight)
|
392
|
+
.css('top', topPos);
|
393
|
+
|
394
|
+
return paneHeight < innerEl.scrollHeight;
|
395
|
+
};
|
396
|
+
|
397
|
+
/**
|
398
|
+
* Called upon drag.
|
399
|
+
*
|
400
|
+
* @api private
|
401
|
+
*/
|
402
|
+
|
403
|
+
Scrollbar.Vertical.prototype.mousemove = function (ev) {
|
404
|
+
var paneHeight = this.pane.el.height(),
|
405
|
+
trackHeight = paneHeight - this.pane.padding * 2,
|
406
|
+
pos = ev.pageY - this.startPageY,
|
407
|
+
barHeight = this.el.height(),
|
408
|
+
innerEl = this.innerEl
|
409
|
+
|
410
|
+
// minimum top is 0, maximum is the track height
|
411
|
+
var y = Math.min(Math.max(pos, 0), trackHeight - barHeight);
|
412
|
+
|
413
|
+
innerEl.scrollTop = (innerEl.scrollHeight - paneHeight)
|
414
|
+
* y / (trackHeight - barHeight);
|
415
|
+
};
|
416
|
+
|
417
|
+
/**
|
418
|
+
* Called upon container mousewheel.
|
419
|
+
*
|
420
|
+
* @api private
|
421
|
+
*/
|
422
|
+
|
423
|
+
Scrollbar.Vertical.prototype.mousewheel = function (ev, delta, x, y) {
|
424
|
+
if ((y > 0 && 0 == this.innerEl.scrollTop) ||
|
425
|
+
(y < 0 && (this.innerEl.scrollTop + Math.ceil(this.pane.el.height())
|
426
|
+
== this.innerEl.scrollHeight))) {
|
427
|
+
ev.preventDefault();
|
428
|
+
return false;
|
429
|
+
}
|
430
|
+
};
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Cross-browser inheritance.
|
434
|
+
*
|
435
|
+
* @param {Function} constructor
|
436
|
+
* @param {Function} constructor we inherit from
|
437
|
+
* @api private
|
438
|
+
*/
|
439
|
+
|
440
|
+
function inherits (ctorA, ctorB) {
|
441
|
+
function f() {};
|
442
|
+
f.prototype = ctorB.prototype;
|
443
|
+
ctorA.prototype = new f;
|
444
|
+
};
|
445
|
+
|
446
|
+
/**
|
447
|
+
* Scrollbar size detection.
|
448
|
+
*/
|
449
|
+
|
450
|
+
var size;
|
451
|
+
|
452
|
+
function scrollbarSize () {
|
453
|
+
if (size === undefined) {
|
454
|
+
var div = $(
|
455
|
+
'<div class="antiscroll-inner" style="width:50px;height:50px;overflow-y:scroll;'
|
456
|
+
+ 'position:absolute;top:-200px;left:-200px;"><div style="height:100px;width:100%"/>'
|
457
|
+
+ '</div>'
|
458
|
+
);
|
459
|
+
|
460
|
+
$('body').append(div);
|
461
|
+
var w1 = $(div).innerWidth();
|
462
|
+
var w2 = $('div', div).innerWidth();
|
463
|
+
$(div).remove();
|
464
|
+
|
465
|
+
size = w1 - w2;
|
466
|
+
}
|
467
|
+
|
468
|
+
return size;
|
469
|
+
};
|
470
|
+
|
471
|
+
})(jQuery);
|
@@ -0,0 +1,60 @@
|
|
1
|
+
.antiscroll-wrap {
|
2
|
+
display: inline-block;
|
3
|
+
position: relative;
|
4
|
+
overflow: hidden;
|
5
|
+
}
|
6
|
+
|
7
|
+
.antiscroll-scrollbar {
|
8
|
+
background: gray;
|
9
|
+
background: rgba(0, 0, 0, 0.5);
|
10
|
+
border-radius: 7px;
|
11
|
+
-webkit-box-shadow: 0 0 1px #fff;
|
12
|
+
box-shadow: 0 0 1px #fff;
|
13
|
+
position: absolute;
|
14
|
+
opacity: 0;
|
15
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
|
16
|
+
-webkit-transition: linear 300ms opacity;
|
17
|
+
-moz-transition: linear 300ms opacity;
|
18
|
+
-o-transition: linear 300ms opacity;
|
19
|
+
}
|
20
|
+
|
21
|
+
.antiscroll-scrollbar-shown {
|
22
|
+
opacity: 1;
|
23
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
|
24
|
+
}
|
25
|
+
|
26
|
+
.antiscroll-scrollbar-horizontal {
|
27
|
+
height: 7px;
|
28
|
+
margin-left: 2px;
|
29
|
+
bottom: 2px;
|
30
|
+
left: 0;
|
31
|
+
}
|
32
|
+
|
33
|
+
.antiscroll-scrollbar-vertical {
|
34
|
+
width: 7px;
|
35
|
+
margin-top: 2px;
|
36
|
+
right: 2px;
|
37
|
+
top: 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
.antiscroll-inner {
|
41
|
+
overflow: scroll;
|
42
|
+
}
|
43
|
+
|
44
|
+
/** A bug in Chrome 25 on Lion requires each selector to have their own
|
45
|
+
blocks. E.g. the following:
|
46
|
+
|
47
|
+
.antiscroll-inner::-webkit-scrollbar, .antiscroll-inner::scrollbar {...}
|
48
|
+
|
49
|
+
causes the width and height rules to be ignored by the browser resulting
|
50
|
+
in both native and antiscroll scrollbars appearing at the same time.
|
51
|
+
*/
|
52
|
+
.antiscroll-inner::-webkit-scrollbar {
|
53
|
+
width: 0;
|
54
|
+
height: 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
.antiscroll-inner::scrollbar {
|
58
|
+
width: 0;
|
59
|
+
height: 0;
|
60
|
+
}
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: antiscroll_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guy Israeli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jquery-mousewheel_rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.11
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.11
|
69
|
+
description: creating OS X Lion type scrollbars - Antiscroll, for Rails!
|
70
|
+
email:
|
71
|
+
- guy.israeli@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- antiscroll_rails.gemspec
|
82
|
+
- lib/antiscroll_rails.rb
|
83
|
+
- lib/antiscroll_rails/version.rb
|
84
|
+
- vendor/javascripts/antiscroll.js
|
85
|
+
- vendor/stylesheets/antiscroll.css
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Antiscroll.js for Rails
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|