Skip to content

Commit

Permalink
Merge branch 'v2.0.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Mar 13, 2021
2 parents 4df6e28 + bf4b0ad commit f7b8417
Show file tree
Hide file tree
Showing 14 changed files with 3,057 additions and 2,007 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vue-handy-scroll

Handy floating scrollbar component for Vue.js v2.6.0+.
Handy floating scrollbar component for Vue 3.

## Synopsis

Expand Down Expand Up @@ -35,6 +35,29 @@ or

## Usage

### Component registration

You can register the component for your app either [globally](https://v3.vuejs.org/guide/component-registration.html#global-registration)

```javascript
import HandyScroll from "vue-handy-scroll";

let app = Vue.createApp({...})
app.component("handy-scroll", HandyScroll);
```

or [locally](https://v3.vuejs.org/guide/component-registration.html#local-registration)

```javascript
import HandyScroll from "vue-handy-scroll";

let app = Vue.createApp({
components: {
"handy-scroll": HandyScroll
}
});
```

### Adding the component in templates

Add the component in your templates as follows:
Expand All @@ -58,9 +81,9 @@ or (in DOM templates):
If the layout of your web page may dynamically change, and these changes affect scrollable containers, then you need a way to update the scrollbar every time the container’s sizes change. This can be done by emitting the event `update` through the _event bus_ provided by the component.

```javascript
import {EventBus} from "vue-handy-scroll";
import HandyScroll from "vue-handy-scroll";
// ... some actions which change the total scroll width of the container ...
EventBus.$emit("update", {sourceElement: this.$el});
HandyScroll.EventBus.emit("update", {sourceElement: this.$el});
```

As demonstrated by the example above, when emitting the event, you may pass a reference to the source element. The component uses this reference to detect which scrollable container is actually affected, and updates only the one that contains the provided source element inside it. If you emit the `update` event without providing the source element, _all_ instances of the component will be updated.
Expand Down Expand Up @@ -119,6 +142,6 @@ You can make the floating scrollbar more “unobtrusive” so that it will appea

## Live demos

Check out live usage examples [here](https://amphiluke.github.io/vue-handy-scroll/dist/).
Check out live usage examples [here](https://amphiluke.github.io/vue-handy-scroll/).

You may also find useful this [vue-handy-scroll Pen Collection](https://codepen.io/collection/naLgyg/?grid_type=list) on Codepen.
Loading

0 comments on commit f7b8417

Please sign in to comment.