Skip to content

Commit 752d4ed

Browse files
committed
Merge branch 'v3' into master
2 parents b4664ea + a74cfb5 commit 752d4ed

15 files changed

+2591
-446
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/*

.eslintrc.json

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{
22
"env": {
33
"browser": true,
4-
"amd": true,
5-
"commonjs": true,
4+
"es6": true,
65
"node": true
76
},
87
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": 6,
10+
"sourceType": "module"
11+
},
912
"rules": {
1013
"array-bracket-spacing": [
1114
"error"
1215
],
16+
"arrow-body-style": [
17+
"warn"
18+
],
19+
"arrow-spacing": [
20+
"error"
21+
],
1322
"block-spacing": [
1423
"error",
1524
"never"
@@ -24,6 +33,9 @@
2433
"comma-style": [
2534
"error"
2635
],
36+
"computed-property-spacing": [
37+
"error"
38+
],
2739
"curly": [
2840
"error"
2941
],
@@ -60,6 +72,10 @@
6072
"new-parens": [
6173
"error"
6274
],
75+
"no-console": [
76+
"error",
77+
{"allow": ["info", "warn", "error"]}
78+
],
6379
"no-multi-spaces": [
6480
"error"
6581
],
@@ -72,19 +88,35 @@
7288
"no-useless-call": [
7389
"error"
7490
],
91+
"no-useless-computed-key": [
92+
"error"
93+
],
94+
"no-var": [
95+
"error"
96+
],
7597
"no-whitespace-before-property": [
7698
"warn"
7799
],
78100
"object-curly-spacing": [
79101
"error"
80102
],
103+
"object-shorthand": [
104+
"warn"
105+
],
81106
"operator-assignment": [
82107
"warn"
83108
],
84109
"operator-linebreak": [
85110
"error",
86111
"after"
87112
],
113+
"prefer-arrow-callback": [
114+
"error",
115+
{"allowNamedFunctions": true}
116+
],
117+
"prefer-rest-params": [
118+
"error"
119+
],
88120
"quotes": [
89121
"error",
90122
"double"

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
bower_components
3-
.eslint*
3+
bower.json
4+
.eslint*
5+
rollup.config.js

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Before submitting a new pull request be sure to do the following things.
1414
* Test your changes in different browsers: Chrome, Firefox, Safari, Opera, Internet Explorer, and Edge.
1515
* Note that the plugin is currently compatible with ancient versions of jQuery (1.4.3+). If your changes break this compatibility please think if you can rewrite your code to keep compatibility unaffected. However if your changes are so important and cool that they outweigh all benefits of supporting ancient versions of jQuery then it is possible to soften this requirement within reasonable limits.
1616
* Before committing your changes please make sure that the plugin sources pass ESLint checks. Just use the command `npm run lint` in the project directory (of course, you need to install the project first by executing `npm install`). Fix any problems reported by ESLint before submitting a pull request.
17-
* Do not forget to update the minified version of the plugin sources. Use the command `npm run minify` for that. If you changed the file of plugin styles (`jquery.floatingscroll.less`) run `npm run make-css` to update the minified CSS file as well.
17+
* Do not forget to update the minified version of the plugin sources. Use the command `npm run build` for that.
1818

1919
Thanks for contribution! :tea:
2020

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,50 @@
22

33
## The Crux of the Matter
44

5-
The general purpose of the plugin is to provide some lengthy containers on the page with a separate horizontal scroll bar, which does not vanish from sight when the entire page is scrolled. So, the user will always be able to scroll the container even if its own scroll bar is hidden from view.
5+
The general purpose of the plugin is to provide some lengthy containers on the page with a separate horizontal scroll bar, which does not vanish from sight when the entire page is scrolled. So, the user will always be able to scroll the container even if its own scroll bar is outside the viewport.
66

7-
Moreover, the plugin displays such an additional floating scroll bar only in case of actual need, i.e. the floatingScroll does not result in unnecessary scroll bar duplication. So, one uses the floating scroll bar only if the “native” one is out of sight.
7+
Moreover, the plugin displays such an additional floating scroll bar only in case of actual need, i.e. floatingScroll does not result in unnecessary scroll bar duplication. So, one uses the floating scroll bar only if the “native” one is out of sight.
88

99
## Details & API
1010

11-
There is the only public method used to instantiate and control a floating scroll — `.floatingScroll()` (note that the old method alias `attachScroll` is kept for backward compatibility, but it will be removed in future versions). The plugin method `.floatingScroll()` should be called in context of a scrollable container. It takes an optional argument `method`. The currently supported methods are
11+
There is the only public method used to instantiate and control a floating scroll — `.floatingScroll()`. The plugin method `.floatingScroll()` should be called in context of a scrollable container. It takes an optional argument `method`. The currently supported methods are
1212

1313
* `init` (default value) — used to initialize a floating scroll widget;
1414
* `update` — used to force update of the floating scroll bar parameters (size and position);
1515
* `destroy` — removes a scroll bar and all related event handlers.
1616

17-
You may also trigger events `update.fscroll` and `destroy.fscroll` for containers with attached floating scroll bar: this does the same as invoking the corresponding methods.
17+
You may also [trigger](https://api.jquery.com/trigger/) events `update.fscroll` and `destroy.fscroll` on containers with attached floating scroll bar: this does the same as invoking the corresponding methods.
1818

1919
## Usage
2020

2121
### Inclusion of plugin files
2222

23-
The plugin requires the CSS file [jquery.floatingscroll.css](src/jquery.floatingscroll.css) to be included on the page (you may also import it in your CSS/LESS files). The plugin's script file [jquery.floatingscroll.min.js](src/jquery.floatingscroll.min.js) may be added on the web page either via a separate `<script>` element or it may be loaded by any AMD/CommonJS compatible module loader. This is a jQuery plugin so be sure that this library is added and accessible.
23+
The plugin requires the CSS file [jquery.floatingscroll.css](dist/jquery.floatingscroll.css) to be included on the page (you may also import it in your CSS/LESS files). The plugin’s script file [jquery.floatingscroll.min.js](dist/jquery.floatingscroll.min.js) may be added on the web page either via a separate `<script>` element, or it may be loaded by any AMD/CommonJS compatible module loader. This is a jQuery plugin so be sure that this library is added and accessible.
24+
25+
:bulb: **Tip:** If you don’t care about supporting old browsers, feel free to use the file [jquery.floatingscroll.es6.min.js](dist/jquery.floatingscroll.es6.min.js), which is de facto the same as jquery.floatingscroll.min.js but is written in ES6, and is a bit smaller.
2426

2527
### Initialisation
2628

27-
The only thing required to apply the floatingScroll to a static container (whose sizes will never change during the session) is a single call of the `.floatingScroll()` method on the DOM ready event:
29+
The only thing required to apply floatingScroll to a static container (whose sizes will never change during the session) is a single call of the `.floatingScroll()` method on the DOM ready event:
2830

2931
```javascript
3032
$(document).ready(function () {
3133
$(".spacious-container").floatingScroll();
3234
});
3335
```
3436

37+
### Auto-initialisation
38+
39+
There is another way of initialising the floatingScroll widget without writing a single line of JavaScript code. Just add an attribute `data-fl-scrolls` to the desired container. As the DOM is ready the plugin will detect all such elements and will do initialisation automatically.
40+
41+
```html
42+
<div class="spacious-container" data-fl-scrolls>
43+
<!-- Horizontally wide contents -->
44+
</div>
45+
```
46+
47+
_The auto-initialisation feature is available starting with v3.0.0._
48+
3549
### Updating scroll bar
3650

3751
If you attach a floating scroll bar to a container whose size and/or content may dynamically change, then you need a way to update the scroll bar each time the container changes. This can be done by invoking the method `update` as in example below.
@@ -72,16 +86,12 @@ The `.fl-scrolls-viewport` element (1) is a positioned block (with any type of p
7286
$(".spacious-container").floatingScroll();
7387
```
7488

75-
The plugin's CSS provides some basic styles for elements with classes `.fl-scrolls-viewport` and `.fl-scrolls-body`. Feel free to adjust their styles in your stylesheets as needed.
89+
The plugins CSS file provides some basic styles for elements with classes `.fl-scrolls-viewport` and `.fl-scrolls-body`. Feel free to adjust their styles in your stylesheets as needed.
7690

7791
### Tips
7892

7993
You can also make a floating scroll bar more “unobtrusive” so that it will appear only when the mouse pointer hovers over the scrollable container. To do so just apply the class `fl-scrolls-hoverable` to the desired scrollable container owning the floating scroll bar.
8094

8195
## Live demos
8296

83-
You may find some demos of use the floatingScroll plugin [here](https://amphiluke.github.io/floating-scroll/).
84-
85-
## Previous versions
86-
87-
Prior to v2.2.0, the plugin was the part of the [jquery-plugins](https://github.com/Amphiluke/jquery-plugins) repo. If for some purpose you want to get commit history for older plugin versions, you can [extract](https://github.com/Amphiluke/jquery-plugins/commits/master/src/floatingscroll) it from that “old” repo.
97+
Check out some usage demos [here](https://amphiluke.github.io/floating-scroll/).

bower.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"bower_components",
3131
"test",
3232
"tests",
33-
"package.json"
33+
"package.json",
34+
"package-lock.json",
35+
"rollup.config.js"
3436
],
3537
"dependencies": {
3638
"jquery": ">=1.4.3"
File renamed without changes.

dist/jquery.floatingscroll.es6.min.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.floatingscroll.min.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

floating-scroll.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "floating-scroll",
33
"title": "floatingScroll",
4-
"version": "2.3.3",
4+
"version": "3.0.0",
55
"description": "A lightweight jQuery plugin providing floating scrollbar functionality",
66
"keywords": [
77
"scrollbar",

0 commit comments

Comments
 (0)