Component
-| - Class: - | -- {{ componentClass }} - | -
| - Description: - | -OverlayScrollbars as a {{ framework }}-Component. | -
-
- {{ loremIpsumShort }} -
-
- {{ loremIpsumShort }} -
-
- {{ loremIpsumLong }} -
- {{ item }} -
diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..31c9b42 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +node_modules +dist +types +.build +.coverage +.nyc_output \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..0b1071e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,125 @@ +const resolve = require('@~local/config/resolve'); + +module.exports = { + extends: ['airbnb', 'prettier'], + env: { + browser: true, + es2020: true, + node: true, + jest: true, + }, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + ecmaVersion: 11, + sourceType: 'module', + }, + settings: { + 'import/resolver': { + node: { + extensions: resolve.extensions, + moduleDirectory: resolve.directories, + }, + }, + }, + plugins: ['prettier', 'json', 'react', 'jest', 'import', '@typescript-eslint'], + rules: { + 'func-names': 'off', + 'no-plusplus': 'off', + 'no-continue': 'off', + 'no-param-reassign': 'off', + 'no-nested-ternary': 'off', + 'no-underscore-dangle': 'off', + 'no-multi-assign': 'off', + 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], + 'no-console': ['error', { allow: ['warn', 'error'] }], + 'no-empty': ['error', { allowEmptyCatch: true }], + 'no-cond-assign': ['error', 'except-parens'], + camelcase: ['error', { allow: ['^__', '^UNSAFE_'] }], + 'prefer-destructuring': 'off', + 'consistent-return': 'off', + 'import/prefer-default-export': 'off', + 'import/no-extraneous-dependencies': 'off', + 'import/no-unresolved': [ + 'error', + { + ignore: [`^@/.*`], + }, + ], + 'import/extensions': [ + 'off', + 'ignorePackages', + { + js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', + }, + ], + }, + overrides: [ + { + files: ['*.ts', '*.tsx', '*.d.ts'], + extends: ['plugin:@typescript-eslint/recommended', 'plugin:react/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./packages/**/tsconfig.json', './local/**/tsconfig.json'], + }, + rules: { + 'no-shadow': 'off', + '@typescript-eslint/no-shadow': ['error'], + 'no-use-before-define': 'off', + '@typescript-eslint/no-use-before-define': ['error'], + 'no-redeclare': 'off', + '@typescript-eslint/no-redeclare': ['error', { ignoreDeclarationMerge: true }], + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['error'], + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/no-this-alias': [ + 'error', + { + allowDestructuring: true, // Allow `const { props, state } = this`; false by default + allowedNames: ['self', '_self'], // Allow `const self = this`; `[]` by default + }, + ], + }, + }, + { + files: ['*.test.*', '**/tests/**'], + rules: { + 'no-shadow': 'off', + 'no-use-before-define': 'off', + 'no-restricted-syntax': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-floating-promises': 'off', + 'no-console': 'off', + 'consistent-return': 'off', + 'symbol-description': 'off', + 'no-new-wrappers': 'off', + 'no-prototype-builtins': 'off', + 'no-void': 'off', + 'no-empty-function': 'off', + 'no-new-func': 'off', + 'import/order': 'off', + }, + }, + { + files: ['*rollup*'], + rules: { + 'no-console': 'off', + 'global-require': 'off', + 'import/no-dynamic-require': 'off', + }, + }, + ], +}; diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 70ffdca..e9a3c3c 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: ['https://www.paypal.me/ReneHaas'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8daac38..db2618b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help improve OverlayScrollbars title: '' labels: '' assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -21,12 +21,13 @@ Steps to reproduce the behavior: A clear and concise description of what you expected to happen. **Examples** -Please create a small example of the bug. +Please create a small example of the bug. To do this you can use online platforms like [JSFiddle](https://jsfiddle.net/), [CodeSandbox](https://codesandbox.io/) or [StackBlitz](https://stackblitz.com/). You can also create a separate Github repository which I can clone. **Environment** - - Used Operating System(s): - - Used Browser(s) (with version): + +- Used Operating System(s): +- Used Browser(s) (with version): **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..2f28cea 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.gitignore b/.gitignore index 4174d89..096f9d4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,16 @@ # dependencies node_modules/ -# dist -example/dist/ -example/build/ +# generated by tools +.build/ +.coverage/ +.nyc_output/ + +# generated by build +packages/**/dist/ +packages/**/styles/ +packages/**/types/ +local/**/dist/ # local env files .env.local diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..20abe4c --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry="https://registry.npmjs.org" \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d54633b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +node_modules +dist +types +.coverage +.build +.nyc_output \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..9b0f0c6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,36 @@ +{ + "printWidth": 100, + "tabWidth": 2, + "singleQuote": true, + "trailingComma": "es5", + "jsxBracketSameLine": true, + "arrowParens": "always", + "endOfLine": "lf", + "parser": "babel-ts", + "overrides": [ + { + "files": "*.html", + "options": { "parser": "html" } + }, + { + "files": "*.css", + "options": { "parser": "css" } + }, + { + "files": "*.scss", + "options": { "parser": "scss" } + }, + { + "files": "*.vue", + "options": { "parser": "vue" } + }, + { + "files": "*.component.html", + "options": { "parser": "angular" } + }, + { + "files": ".prettierrc", + "options": { "parser": "json" } + } + ] +} diff --git a/README.md b/README.md index 71cbc1b..7510c85 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,14 @@
| option | -type | -default | -description | -|
|---|---|---|---|---|
| className | -string / null | -"os-theme-dark" |
- The class name which shall be added to the host element. | -|
| resize | -string | -"none" |
- The resize behavior of the host element. This option works exactly like the CSS3 resize property. | -|
| sizeAutoCapable | -boolean | -true |
- Indicates whether the host element is capable of "auto" sizes such as: width: auto and height: auto. |
- |
| clipAlways | -boolean | -true |
- Indicates whether the content shall be clipped always. | -|
| normalizeRTL | -boolean | -true |
- Indicates whether RTL scrolling shall be normalized. | -|
| paddingAbsolute | -boolean | -false |
- Indicates whether the padding for the content shall be absolute. | -|
| autoUpdate | -boolean / null | -null |
- Indicates whether the plugin instance shall be updated continuously within a update loop. | -|
| autoUpdateInterval | -number | -33 |
- The interval in milliseconds in which a auto update shall be performed for this instance. | -|
| updateOnLoad | -string / array / null | -["img"] |
- Selectors of which the elements load event shall be handled by the plugin. Thats means OverlayScrollbars will trigger a automatic update if a element with a matching selector emits a load event. Per default OverlayScrollbars will update automatically if a img element loads. |
- |
| nativeScrollbarsOverlaid : { | -||||
| - | showNativeScrollbars | -boolean | -false |
- Indicates whether the native overlaid scrollbars shall be visible. | -
| - | initialize | -boolean | -true |
-
- Indicates whether the plugin shall be initialized even if the native scrollbars are overlaid. - If you initialize the plugin on the body element, I recommend to set this option to false. - |
-
| } | -||||
| overflowBehavior : { | -||||
| - | x | -string | -"scroll" |
- The overflow behavior for the x (horizontal) axis. | -
| - | y | -string | -"scroll" |
- The overflow behavior for the y (vertical) axis. | -
| } | -||||
| scrollbars : { | -||||
| - | visibility | -string | -"auto" |
- The basic visibility of the scrollbars. | -
| - | autoHide | -string | -"never" |
- The possibility to hide visible scrollbars automatically after a certain action. | -
| - | autoHideDelay | -number | -800 |
- The delay in milliseconds before the scrollbars gets hidden automatically. | -
| - | dragScrolling | -boolean | -true |
- Defines whether the scrollbar-handle supports drag scrolling. | -
| - | clickScrolling | -boolean | -false |
- Defines whether the scrollbar-track supports click scrolling. | -
| - | touchSupport | -boolean | -true |
- Indicates whether the scrollbar reacts to touch events. | -
| - | snapHandle | -boolean | -false |
- Indicates whether the scrollbar handle-offset shall be snapped. | -
| } | -||||
| textarea : { | -||||
| - | dynWidth | -boolean | -false |
- Indicates whether the textarea width will be dynamic (content dependent). | -
| - | dynHeight | -boolean | -false |
- Indicates whether the textarea height will be dynamic (content dependent). | -
| - | inheritedAttrs | -string / array / null | -["style", "class"] |
- During initialization: Attributes which the generated host-element shall inherit from from the target textarea-element. -During destruction: Attributes which the target textarea-element shall inherit from from the generated host-element. |
-
| } | -||||
| callbacks : { | -||||
| - | onInitialized | -function / null | -null |
- Gets fired after the plugin was initialized. It takes no arguments. | -
| - | onInitializationWithdrawn | -function / null | -null |
- Gets fired after the initialization of the plugin was aborted due to the option nativeScrollbarsOverlaid : { initialize : false }. It takes no arguments. |
-
| - | onDestroyed | -function / null | -null |
- Gets fired after the plugin was destryoed. It takes no arguments. | -
| - | onScrollStart | -function / null | -null |
- Gets fired after the user starts scrolling. It takes one argument. | -
| - | onScroll | -function / null | -null |
- Gets fired after every scroll. It takes one argument. | -
| - | onScrollStop | -function / null | -null |
- Gets fired after the user stops scrolling. It takes one argument. | -
| - | onOverflowChanged | -function / null | -null |
- Gets fired after the overflow has changed. It takes one argument. | -
| - | onOverflowAmountChanged | -function / null | -null |
- Gets fired after the overflow amount has changed. It takes one argument. | -
| - | onDirectionChanged | -function / null | -null |
- Gets fired after the direction has changed. It takes one argument. | -
| - | onContentSizeChanged | -function / null | -null |
- Gets fired after the content size has changed. It takes one argument. | -
| - | onHostSizeChanged | -function / null | -null |
- Gets fired after the host size or host padding has changed. It takes one argument. | -
| - | onUpdated | -function / null | -null |
- Gets fired after the host size has changed. It takes one argument. | -
| } | -||||
| name | -description | -
|---|---|
| .options() | -Returns or sets the options of the instance. | -
|
- example(s): -
-//get options
-var options = instance.options();
-//set options
-instance.options({ className : null });
- |
- |
| .update() | -Updates the instance. | -
|
- example(s): -
-//soft update
-instance.update();
-//hard update
-instance.update(true);
- |
- |
| .sleep() | -Disables every observation of the DOM and puts the instance to "sleep". This behavior can be reset by calling the update() method. |
-
|
- example(s): -
-//put the instance to sleep
-instance.sleep();
- |
- |
| .scroll() | -Returns the scroll information or sets the scroll position. | -
|
- example(s): -
-//get scroll information
-var scrollInfo = instance.scroll();
-//scroll 50px on both axis
-instance.scroll(50);
-//add 10px to the scroll offset of each axis
-instance.scroll({ x : "+=10", y : "+=10" });
-//scroll to 50% on both axis with a duration of 1000ms
-instance.scroll({ x : "50%", y : "50%" }, 1000);
-//scroll to the passed element with a duration of 1000ms
-instance.scroll($(selector), 1000);
- |
- |
| .scrollStop() | -Stops the current scroll-animation. | -
|
- example(s): -
-//scroll-animation duration is 10 seconds
-instance.scroll({ y : "100%" }, 10000);
-//abort the 10 seconds scroll-animation immediately
-instance.scrollStop();
-//scroll-animation duration is 1 second
-instance.scroll({ y : "100%" }, 1000);
- |
- |
| .getElements() | -Returns all relevant elements. | -
|
- example(s): -
-//get the element to which the plugin was applied
-var pluginTarget = instance.getElements().target;
- |
- |
| .getState() | -Returns a object which describes the current state of this instance. | -
|
- example(s): -
-//get the state of the plugin instance
-var pluginState = instance.getState();
- |
- |
| .destroy() | -Destroys and disposes the current instance and removes all added elements form the DOM. | -
|
- example(s): -
-//destroy the instance
-instance.destroy();
- |
- |
| .ext() | -Returns the instance of a certain extension of the current plugin instance. | -
|
- example(s): -
-//get the instance of the extension "myExtension"
-var extensionInstance = instance.ext("myExtension");
- |
- |
| .addExt() | -Adds a extension to the current instance. | -
|
- example(s): -
-//add the registered extension "myExtension" to the plugin instance
-var extensionInstance = instance.addExt("myExtension");
- |
- |
| .removeExt() | -Removes a extension from the current instance. | -
|
- example(s): -
-//add the registered extension "myExtension" to the plugin instance
-instance.addExt("myExtension");
-//remove the added extension "myExtension" from the plugin instance
-instance.removeExt("myExtension");
- |
- |
| name | -description | -
|---|---|
| OverlayScrollbars.defaultOptions() | -Returns or Sets the default options for each new plugin initialization. | -
|
- example(s): -
-//get the current defaultOptions
-var defaultOptions = OverlayScrollbars.defaultOptions();
-//set new default options
-OverlayScrollbars.defaultOptions({
- className : "my-custom-class",
- resize : "both"
-});
- |
- |
| OverlayScrollbars.globals() | -Returns a plain object which contains global information about the plugin and each instance of it. | -
|
- example(s): -
-//get the global information
-var globals = OverlayScrollbars.globals();
- |
- |
| OverlayScrollbars.extension() | -Registers, Unregisters or returns extensions. | -
|
- example(s): -
-//register a dummy extension with the name "myExtension"
-OverlayScrollbars.extension("myExtension", function() { return { }; });
-//unregister the extension with the name "myExtension"
-OverlayScrollbars.extension("myExtension", null);
-//get the extension-object with the name "myExtension"
-var registeredExtension = OverlayScrollbars.extension("myExtension");
-//get all registered extension-objects
-var extensionObjects = OverlayScrollbars.extension();
- |
- |
| OverlayScrollbars.valid() | -Checks whether the passed object is a non-destroyed OverlayScrollbars instance. | -
|
- example(s): -
-//create OverlayScrollbars instance
-var osInstance = OverlayScrollbars(document.body, { });
-//returns true
-OverlayScrollbars.valid(osInstance);
-//destroy the instance
-osInstance.destroy();
-//returns false
-OverlayScrollbars.valid(osInstance);
-//returns false
-OverlayScrollbars.valid({ });
- |
- |
- import
- {{ " { " }}
- OverlayScrollbarsComponent
- {{ " } " }}
- from
- {{ " 'overlayscrollbars-ngx'" }}
- ;
-
-| - Class: - | -- {{ componentClass }} - | -
| - Description: - | -OverlayScrollbars as a {{ framework }}-Component. | -
- import
- {' { '}
- OverlayScrollbarsComponent
- {' } '}
- from
- {" 'overlayscrollbars-react'"}
- ;
-
- | Class: | -{this.componentClass} | -
| Description: | -OverlayScrollbars as a {this.framework}-Component. | -
- import
- {{ " { " }}
- OverlayScrollbarsComponent
- {{ " } " }}
- from
- {{ " 'overlayscrollbars-vue'" }}
- ;
-
- | - Class: - | -- {{ componentClass }} - | -
| - Description: - | -OverlayScrollbars as a {{ framework }}-Component. | -
+
+
+
+
+
+
+ |
+ + Thanks to BrowserStack for sponsoring open source projects and letting me test OverlayScrollbars for free. + | +