diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4be6e16 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist/* \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index ab7cdea..2be75aa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,15 +1,24 @@ { "env": { "browser": true, - "amd": true, - "commonjs": true, + "es6": true, "node": true }, "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, "rules": { "array-bracket-spacing": [ "error" ], + "arrow-body-style": [ + "warn" + ], + "arrow-spacing": [ + "error" + ], "block-spacing": [ "error", "never" @@ -24,6 +33,9 @@ "comma-style": [ "error" ], + "computed-property-spacing": [ + "error" + ], "curly": [ "error" ], @@ -60,6 +72,10 @@ "new-parens": [ "error" ], + "no-console": [ + "error", + {"allow": ["info", "warn", "error"]} + ], "no-multi-spaces": [ "error" ], @@ -72,12 +88,21 @@ "no-useless-call": [ "error" ], + "no-useless-computed-key": [ + "error" + ], + "no-var": [ + "error" + ], "no-whitespace-before-property": [ "warn" ], "object-curly-spacing": [ "error" ], + "object-shorthand": [ + "warn" + ], "operator-assignment": [ "warn" ], @@ -85,6 +110,13 @@ "error", "after" ], + "prefer-arrow-callback": [ + "error", + {"allowNamedFunctions": true} + ], + "prefer-rest-params": [ + "error" + ], "quotes": [ "error", "double" diff --git a/.npmignore b/.npmignore index abed34b..1de16a8 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,5 @@ .idea bower_components -.eslint* \ No newline at end of file +bower.json +.eslint* +rollup.config.js \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d33eb68..765b2b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Before submitting a new pull request be sure to do the following things. * Test your changes in different browsers: Chrome, Firefox, Safari, Opera, Internet Explorer, and Edge. * 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. * 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. -* 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. +* Do not forget to update the minified version of the plugin sources. Use the command `npm run build` for that. Thanks for contribution! :tea: diff --git a/README.md b/README.md index 1192d41..0ffe67f 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,31 @@ ## The Crux of the Matter -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. +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. -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. +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. ## Details & API -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 +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 * `init` (default value) — used to initialize a floating scroll widget; * `update` — used to force update of the floating scroll bar parameters (size and position); * `destroy` — removes a scroll bar and all related event handlers. -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. +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. ## Usage ### Inclusion of plugin files -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 `