Skip to content

Commit

Permalink
1.1.7 - Add closed and opened events
Browse files Browse the repository at this point in the history
  • Loading branch information
vaban-ru committed Feb 7, 2021
1 parent 2d964fe commit 6c8d53b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ Vue.use(VueBottomSheet);
| max-height | String | Set max-height of component card | `max-height="90%"` |
| effect | String | Set effect for component card | `effect="fx-fadein-scale"` |

## Events

| Event | Description | Example |
| ------------- | ------------- | ------------- |
| opened | Fire when card component is opened | @opened="" |
| closed | Fire when card component is closed | @closed="" |

### List of effects

- fx-default
Expand Down
8 changes: 8 additions & 0 deletions README_RU.MD
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Vue.use(VueBottomSheet);
| max-height | String | Устанавливает максимальную высоту карточки компонента | `max-height="90%"` |
| effect | String | Устанавливает эффект появление карточки компонента | `effect="fx-fadein-scale"` |

## События

| Событие | Описание | Пример |
| ------------- | ------------- | ------------- |
| opened | Срабатывает при открытии компонента | @opened="" |
| closed | Срабатывает при закрытии компонента | @closed="" |


### Список эффектов

- fx-default
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webzlodimir/vue-bottom-sheet",
"version": "1.1.6",
"version": "1.1.7",
"description": "",
"main": "dist/vue-bottom-sheet.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/components/VueBottomSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
this.mc.on("panstart", () => {
this.moving = true;
});
this.mc.on("panup pandown", evt => {
this.mc.on("pandown", evt => {
const panPosition =
this.$refs.bottomSheet.clientHeight - this.cardH - evt.center.y;
if (panPosition < 0) {
Expand All @@ -116,6 +116,11 @@ export default {
this.opened = false;
this.cardP = `-${this.cardH + this.stripe}px`;
document.querySelector("body").style.overflow = "";
if (evt.isFinal) {
console.log("closed");
}
this.mc.off("panend");
this.$emit("closed");
}
});
resolve();
Expand All @@ -127,6 +132,7 @@ export default {
this.opened = true;
this.cardP = 0;
document.querySelector("body").style.overflow = "hidden";
this.$emit("opened");
});
},
close() {
Expand All @@ -137,6 +143,7 @@ export default {
? 0
: `-${this.cardH + this.stripe}px`;
document.querySelector("body").style.overflow = "";
this.$emit("closed");
},
clickOnBottomSheet(event) {
const clickedBlock = event.target;
Expand Down

0 comments on commit 6c8d53b

Please sign in to comment.