jscrollpane-rails 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c15c972ab89b174afc35bf344794b048931d0cc9999c65636ba6abed26a826d
4
- data.tar.gz: 74f378e3a67dc80c9245f7f575844763b01687e9e0ad0fd4a7c0994a97682448
3
+ metadata.gz: bd6a603883bd23cc7d09a3a94a6b6f2b433e571d4a44f256244fbb5f4e80ed66
4
+ data.tar.gz: 2ad16320b795bc7a3618bd2d10c43d5d09127cd6febc0a37199747e961e7531c
5
5
  SHA512:
6
- metadata.gz: d936c215413507def66dd9eac6b87d54d3c9908bf0a3d5bc7338d9f88cadbaa4da7b3688eb05220058e51d4819e535357bc6debafab53669b406867bc78a5eca
7
- data.tar.gz: 7c31b7bf374ced64f9e84e513125a021a35a7c0683da4874553c507e2443496cc72ed2927618ea5ccc40f711396fb51655945e454177d68bdbeb68a797461a6b
6
+ metadata.gz: 84e2c98f713d57bc65c75cdc7247b876fd3920d3f64ab36060c3c3551d384bf0eef95ae6c1892db9c98b5ba5a6316330754b593d0bdc2024b5f093b22c6078cf
7
+ data.tar.gz: '0330538e6d802cb84f13eb914652c421b6a8222bfc942306212f22160ae0d1c950cde54b6c53f9d0fb5ee9c177d2a8fa9113770c44eb2da3c7d513fe6c4baabd'
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/jscrollpane-rails.png)](http://badge.fury.io/rb/jscrollpane-rails)
4
4
  [![Build Status](https://travis-ci.org/bodrovis/jscrollpane-rails.svg?branch=master)](https://travis-ci.org/bodrovis/jscrollpane-rails)
5
- [![Dependency Status](https://gemnasium.com/badges/github.com/bodrovis/jscrollpane-rails.svg)](https://gemnasium.com/github.com/bodrovis/jscrollpane-rails)
6
5
 
7
6
  A ruby gem that uses the Rails asset pipeline to include the jScrollPane plugin by Kelvin Luck and Tuukka Pasanen:
8
7
 
@@ -54,7 +53,7 @@ In your `application.js` you will need to add this line:
54
53
  And in your `application.scss` you will need to add this line:
55
54
 
56
55
  ```scss
57
- @import 'jscrollpane';
56
+ @import 'jquery.jscrollpane';
58
57
  ```
59
58
 
60
59
  ## Testing
@@ -81,6 +80,6 @@ $ rake test
81
80
 
82
81
  ## License
83
82
 
84
- This plugin is licensed under the [MIT License](https://github.com/bodrovis/jscrollpane-rails/blob/master/LICENSE).
83
+ This plugin is licensed under the [MIT license](https://github.com/bodrovis/jscrollpane-rails/blob/master/LICENSE). The jScrollPane itself is dual-licensed under the [GPL 2 license](https://github.com/vitch/jScrollPane/blob/master/GPL-LICENSE.txt) and the MIT license.
85
84
 
86
85
  Copyright (c) 2018 [Ilya Bodrov](http://bodrovis.tech)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jScrollPane - v2.1.1 - 2018-01-12
2
+ * jScrollPane - v2.2.1 - 2018-09-27
3
3
  * http://jscrollpane.kelvinluck.com/
4
4
  *
5
5
  * Copyright (c) 2014 Kelvin Luck
@@ -9,12 +9,15 @@
9
9
 
10
10
  // Script: jScrollPane - cross browser customisable scrollbars
11
11
  //
12
- // *Version: 2.1.1, Last updated: 2018-01-12*
12
+ // *Version: 2.2.1, Last updated: 2018-09-27*
13
13
  //
14
14
  // Project Home - http://jscrollpane.kelvinluck.com/
15
15
  // GitHub - http://github.com/vitch/jScrollPane
16
- // Source - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.js
17
- // (Minified) - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.min.js
16
+ // CND - https://cdnjs.com/libraries/jScrollPane
17
+ // Source - https://cdnjs.cloudflare.com/ajax/libs/jScrollPane/2.2.1/script/jquery.jscrollpane.min.js
18
+ // (Minified) - https://cdnjs.cloudflare.com/ajax/libs/jScrollPane/2.2.1/script/jquery.jscrollpane.js
19
+ // CSS - https://cdnjs.cloudflare.com/ajax/libs/jScrollPane/2.2.1/style/jquery.jscrollpane.css
20
+ // (Minified) - https://cdnjs.cloudflare.com/ajax/libs/jScrollPane/2.2.1/style/jquery.jscrollpane.min.css
18
21
  //
19
22
  // About: License
20
23
  //
@@ -42,7 +45,28 @@
42
45
  //
43
46
  // About: Release History
44
47
  //
45
- // 2.1.1 - (2018-01-12) As everyone stays silent then we just release! No changes from RC.1
48
+ // 2.2.1 - (2018-09-27) No changed applied to release so same as RC1/2
49
+ // 2.2.1-rc.2 - (2018-06-14) Sucked NPM release have to make new Release.. this is 2018!
50
+ // 2.2.1-rc.1 - (2018-06-14) Fixed CSSLint warnings which can lead CSS problems in
51
+ // production! Please report a issue if this breaks something!
52
+ // * Merged:
53
+ // - #360 Register to globally available version of jQuery
54
+ // 2.2.0 - (2018-05-16) No changes to RC1
55
+ // 2.2.0-rc.1 - (2018-04-28) Merged resize sensor to find out size changes of screen and
56
+ // again little bit tuned this to support more npm goodies.
57
+ // * Merged:
58
+ // - #361 Event based reinitialising - Resize Sensor
59
+ // - #359 Use npm scripts and local dev dependencies to build the project
60
+ // 2.1.3 - (2018-04-04) No changes from Release Candidate 2 so making release
61
+ // 2.1.3-rc.2 - (2018-03-13) Now using 'script/jquery.jscrollpane.min.js' main
62
+ // in package.json rather than 'Gruntfile.js'
63
+ // 2.1.3-rc.1 - (2018-03-05) Moving Gruntfile.js to root and example HTML
64
+ // to subdirectory examples
65
+ // 2.1.2 - (2018-02-16) Just on console.log remove and Release!
66
+ // This version should play nicely with NPM
67
+ // 2.1.2-rc.2 - (2018-02-03) Update package.json main-tag
68
+ // 2.1.2-rc.1 - (2018-01-18) Release on NPM.
69
+ // 2.1.1 - (2018-01-12) As everyone stays silent then we just release! No changes from RC.1
46
70
  // 2.1.1-rc.1 - (2017-12-23) Started to slowly merge stuff (HO HO HO Merry Christmas!)
47
71
  // * Merged
48
72
  // - #349 - ScrollPane reinitialization should adapt to changed container size
@@ -51,17 +75,6 @@
51
75
  // * Bugs
52
76
  // - #8 Make it possible to tell a scrollbar to be "always on"
53
77
  // 2.1.0 - (2017-12-16) Update jQuery to version 3.x
54
- // 2.0.23 - (2016-01-28) Various
55
- // 2.0.22 - (2015-04-25) Resolve a memory leak due to an event handler that isn't cleaned up in destroy (thanks @timjnh)
56
- // 2.0.21 - (2015-02-24) Simplify UMD pattern: fixes browserify when loading jQuery outside of bundle
57
- // 2.0.20 - (2014-10-23) Adds AMD support (thanks @carlosrberto) and support for overflow-x/overflow-y (thanks @darimpulso)
58
- // 2.0.19 - (2013-11-16) Changes for more reliable scroll amount with latest mousewheel plugin (thanks @brandonaaron)
59
- // 2.0.18 - (2013-10-23) Fix for issue with gutters and scrollToElement (thanks @Dubiy)
60
- // 2.0.17 - (2013-08-17) Working correctly when box-sizing is set to border-box (thanks @pieht)
61
- // 2.0.16 - (2013-07-30) Resetting left position when scroll is removed. Fixes #189
62
- // 2.0.15 - (2013-07-29) Fixed issue with scrollToElement where the destX and destY are undefined.
63
- // 2.0.14 - (2013-05-01) Updated to most recent mouse wheel plugin (see #106) and related changes for sensible scroll speed
64
- // 2.0.13 - (2013-05-01) Switched to semver compatible version name
65
78
 
66
79
  (function (factory) {
67
80
  if ( typeof define === 'function' && define.amd ) {
@@ -69,7 +82,7 @@
69
82
  define(['jquery'], factory);
70
83
  } else if (typeof exports === 'object') {
71
84
  // Node/CommonJS style for Browserify
72
- module.exports = factory(require('jquery'));
85
+ module.exports = factory(jQuery || require('jquery'));
73
86
  } else {
74
87
  // Browser globals
75
88
  factory(jQuery);
@@ -88,9 +101,21 @@
88
101
  horizontalBar, horizontalTrack, horizontalTrackWidth, horizontalDragWidth, arrowLeft, arrowRight,
89
102
  reinitialiseInterval, originalPadding, originalPaddingTotalWidth, previousContentWidth,
90
103
  wasAtTop = true, wasAtLeft = true, wasAtBottom = false, wasAtRight = false,
91
- originalElement = elem.clone(false, false).empty(),
104
+ originalElement = elem.clone(false, false).empty(), resizeEventsAdded = false,
92
105
  mwEvent = $.fn.mwheelIntent ? 'mwheelIntent.jsp' : 'mousewheel.jsp';
93
106
 
107
+ var reinitialiseFn = function() {
108
+ // if size has changed then reinitialise
109
+ if (settings.resizeSensorDelay > 0) {
110
+ setTimeout(function() {
111
+ initialise(settings);
112
+ }, settings.resizeSensorDelay);
113
+ }
114
+ else {
115
+ initialise(settings);
116
+ }
117
+ };
118
+
94
119
  if (elem.css('box-sizing') === 'border-box') {
95
120
  originalPadding = 0;
96
121
  originalPaddingTotalWidth = 0;
@@ -161,7 +186,6 @@
161
186
 
162
187
  newPaneWidth = elem.innerWidth() + originalPaddingTotalWidth;
163
188
  newPaneHeight = elem.innerHeight();
164
- console.log('newPaneHeight = ' + newPaneHeight);
165
189
  pane.css('position', 'absolute');
166
190
 
167
191
  maintainAtBottom = settings.stickToBottom && isCloseToBottom();
@@ -200,8 +224,6 @@
200
224
  isScrollableV = percentInViewV > 1 || settings.alwaysShowVScroll;
201
225
  isScrollableH = percentInViewH > 1 || settings.alwaysShowHScroll;
202
226
 
203
- //console.log(paneWidth, paneHeight, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableH, isScrollableV);
204
-
205
227
  if (!(isScrollableH || isScrollableV)) {
206
228
  elem.removeClass('jspScrollable');
207
229
  pane.css({
@@ -248,7 +270,7 @@
248
270
  }
249
271
  }
250
272
 
251
- if (settings.autoReinitialise && !reinitialiseInterval) {
273
+ if (!settings.resizeSensor && settings.autoReinitialise && !reinitialiseInterval) {
252
274
  reinitialiseInterval = setInterval(
253
275
  function()
254
276
  {
@@ -256,10 +278,27 @@
256
278
  },
257
279
  settings.autoReinitialiseDelay
258
280
  );
259
- } else if (!settings.autoReinitialise && reinitialiseInterval) {
281
+ } else if (!settings.resizeSensor && !settings.autoReinitialise && reinitialiseInterval) {
260
282
  clearInterval(reinitialiseInterval);
261
283
  }
262
284
 
285
+ if(settings.resizeSensor && !resizeEventsAdded) {
286
+
287
+ // detect size change in content
288
+ detectSizeChanges(pane, reinitialiseFn);
289
+
290
+ // detect size changes of scroll element
291
+ detectSizeChanges(elem, reinitialiseFn);
292
+
293
+ // detect size changes of container
294
+ detectSizeChanges(elem.parent(), reinitialiseFn);
295
+
296
+ // add a reinit on window resize also for safety
297
+ window.addEventListener('resize', reinitialiseFn);
298
+
299
+ resizeEventsAdded = true;
300
+ }
301
+
263
302
  if(originalScrollTop && elem.scrollTop(0)) {
264
303
  scrollToY(originalScrollTop, false);
265
304
  }
@@ -271,6 +310,88 @@
271
310
  elem.trigger('jsp-initialised', [isScrollableH || isScrollableV]);
272
311
  }
273
312
 
313
+ function detectSizeChanges(element, callback) {
314
+
315
+ // create resize event elements - based on resize sensor: https://github.com/flowkey/resize-sensor/
316
+ var resizeWidth, resizeHeight;
317
+ var resizeElement = document.createElement('div');
318
+ var resizeGrowElement = document.createElement('div');
319
+ var resizeGrowChildElement = document.createElement('div');
320
+ var resizeShrinkElement = document.createElement('div');
321
+ var resizeShrinkChildElement = document.createElement('div');
322
+
323
+ // add necessary styling
324
+ resizeElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';
325
+ resizeGrowElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';
326
+ resizeShrinkElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';
327
+
328
+ resizeGrowChildElement.style.cssText = 'position: absolute; left: 0; top: 0;';
329
+ resizeShrinkChildElement.style.cssText = 'position: absolute; left: 0; top: 0; width: 200%; height: 200%;';
330
+
331
+ // Create a function to programmatically update sizes
332
+ var updateSizes = function() {
333
+
334
+ resizeGrowChildElement.style.width = resizeGrowElement.offsetWidth + 10 + 'px';
335
+ resizeGrowChildElement.style.height = resizeGrowElement.offsetHeight + 10 + 'px';
336
+
337
+ resizeGrowElement.scrollLeft = resizeGrowElement.scrollWidth;
338
+ resizeGrowElement.scrollTop = resizeGrowElement.scrollHeight;
339
+
340
+ resizeShrinkElement.scrollLeft = resizeShrinkElement.scrollWidth;
341
+ resizeShrinkElement.scrollTop = resizeShrinkElement.scrollHeight;
342
+
343
+ resizeWidth = element.width();
344
+ resizeHeight = element.height();
345
+ };
346
+
347
+ // create functions to call when content grows
348
+ var onGrow = function() {
349
+
350
+ // check to see if the content has change size
351
+ if (element.width() > resizeWidth || element.height() > resizeHeight) {
352
+
353
+ // if size has changed then reinitialise
354
+ callback.apply(this, []);
355
+ }
356
+ // after reinitialising update sizes
357
+ updateSizes();
358
+ };
359
+
360
+ // create functions to call when content shrinks
361
+ var onShrink = function() {
362
+
363
+ // check to see if the content has change size
364
+ if (element.width() < resizeWidth || element.height() < resizeHeight) {
365
+
366
+ // if size has changed then reinitialise
367
+ callback.apply(this, []);
368
+ }
369
+ // after reinitialising update sizes
370
+ updateSizes();
371
+ };
372
+
373
+ // bind to scroll events
374
+ resizeGrowElement.addEventListener('scroll', onGrow.bind(this));
375
+ resizeShrinkElement.addEventListener('scroll', onShrink.bind(this));
376
+
377
+ // nest elements before adding to pane
378
+ resizeGrowElement.appendChild(resizeGrowChildElement);
379
+ resizeShrinkElement.appendChild(resizeShrinkChildElement);
380
+
381
+ resizeElement.appendChild(resizeGrowElement);
382
+ resizeElement.appendChild(resizeShrinkElement);
383
+
384
+ element.append(resizeElement);
385
+
386
+ // ensure parent element is not statically positioned
387
+ if(window.getComputedStyle(element[0], null).getPropertyValue('position') === 'static') {
388
+ element[0].style.position = 'relative';
389
+ }
390
+
391
+ // update sizes initially
392
+ updateSizes();
393
+ }
394
+
274
395
  function initialiseVerticalScroll()
275
396
  {
276
397
  if (isScrollableV) {
@@ -1534,6 +1655,8 @@
1534
1655
  scrollPagePercent : 0.8, // Percent of visible area scrolled when pageUp/Down or track area pressed
1535
1656
  alwaysShowVScroll : false,
1536
1657
  alwaysShowHScroll : false,
1658
+ resizeSensor : false,
1659
+ resizeSensorDelay : 0,
1537
1660
  };
1538
1661
 
1539
1662
  }));
@@ -18,22 +18,22 @@
18
18
 
19
19
  .jspVerticalBar
20
20
  {
21
+ background: red;
22
+ height: 100%;
21
23
  position: absolute;
22
- top: 0;
23
24
  right: 0;
25
+ top: 0;
24
26
  width: 16px;
25
- height: 100%;
26
- background: red;
27
27
  }
28
28
 
29
29
  .jspHorizontalBar
30
30
  {
31
- position: absolute;
31
+ background: red;
32
32
  bottom: 0;
33
+ height: 16px;
33
34
  left: 0;
35
+ position: absolute;
34
36
  width: 100%;
35
- height: 16px;
36
- background: red;
37
37
  }
38
38
 
39
39
  .jspCap
@@ -55,10 +55,10 @@
55
55
  .jspDrag
56
56
  {
57
57
  background: #bbd;
58
+ cursor: pointer;
59
+ left: 0;
58
60
  position: relative;
59
61
  top: 0;
60
- left: 0;
61
- cursor: pointer;
62
62
  }
63
63
 
64
64
  .jspHorizontalBar .jspTrack,
@@ -71,17 +71,18 @@
71
71
  .jspArrow
72
72
  {
73
73
  background: #50506d;
74
- text-indent: -20000px;
75
- display: block;
76
74
  cursor: pointer;
77
- padding: 0;
75
+ direction: ltr;
76
+ display: block;
78
77
  margin: 0;
78
+ padding: 0;
79
+ text-indent: -20000px;
79
80
  }
80
81
 
81
- .jspArrow.jspDisabled
82
+ .jspDisabled
82
83
  {
83
- cursor: default;
84
84
  background: #80808d;
85
+ cursor: default;
85
86
  }
86
87
 
87
88
  .jspVerticalBar .jspArrow
@@ -91,13 +92,14 @@
91
92
 
92
93
  .jspHorizontalBar .jspArrow
93
94
  {
94
- width: 16px;
95
95
  float: left;
96
96
  height: 100%;
97
+ width: 16px;
97
98
  }
98
99
 
99
100
  .jspVerticalBar .jspArrow:focus
100
101
  {
102
+ border: 1px solid red;
101
103
  outline: none;
102
104
  }
103
105
 
@@ -1,5 +1,5 @@
1
1
  module JScrollPane
2
2
  module Rails
3
- VERSION = "2.1.1"
3
+ VERSION = '2.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscrollpane-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -63,7 +63,7 @@ files:
63
63
  - LICENSE
64
64
  - README.md
65
65
  - app/assets/javascripts/jquery.jscrollpane.js
66
- - app/assets/stylesheets/jscrollpane.css
66
+ - app/assets/stylesheets/jquery.jscrollpane.css
67
67
  - lib/jscrollpane-rails.rb
68
68
  - lib/jscrollpane-rails/version.rb
69
69
  homepage: https://github.com/bodrovis/jscrollpane-rails
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.7.4
89
+ rubygems_version: 2.7.8
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Includes javascript and css files for the jScrollPane plugin.