Skip to content

Commit 3a6f337

Browse files
authored
Merge pull request #15 from veguss/master
add background scrollable and background clickable features
2 parents a1d7882 + ac672b3 commit 3a6f337

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

README.MD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Vue.use(VueBottomSheet);
7373
| is-full-screen | Boolean | Enable or disable full-screen mode | `:is-full-screen="true"` |
7474
| swipe-able | Boolean | Enable or disable swipe to close | `:swipe-able="false"` |
7575
| overlay-color | Boolean | Set overlay color with opacity | `:overlay-color="#0000004D"` |
76+
| background-scrollable | Boolean | Enable scroll | `:background-scrollable="true"` |
77+
| background-clickable | Boolean | Enable background click, doesn't work if `click-to-close=true` | `:background-clickable="true"` |
7678

7779
## Events
7880

dev/serve.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@
7272
>Full Screen</label
7373
>
7474
</div>
75+
<div class="form-check form-switch mb-3">
76+
<input
77+
class="form-check-input"
78+
type="checkbox"
79+
id="srollableSwitchCheckChecked"
80+
v-model="backgroundScrollable"
81+
/>
82+
<label class="form-check-label" for="srollableSwitchCheckChecked"
83+
>Background scrollable</label
84+
>
85+
</div>
86+
<div class="form-check form-switch mb-3">
87+
<input
88+
class="form-check-input"
89+
type="checkbox"
90+
id="clickableSwitchCheckChecked"
91+
v-model="backgroundClickable"
92+
/>
93+
<label class="form-check-label" for="clickableSwitchCheckChecked"
94+
>Background clickable</label
95+
>
96+
</div>
7597
</div>
7698
<div class="col-md-4 col-12">
7799
<div class="mb-3">
@@ -136,6 +158,8 @@
136158
:swipeAble="swipeAble"
137159
:overlayColor="overlyHexColor"
138160
:isFullScreen="isFullScreen"
161+
:backgroundScrollable="backgroundScrollable"
162+
:backgroundClickable="backgroundClickable"
139163
ref="myBottomSheet"
140164
>
141165
<div class="sheet-content">
@@ -200,7 +224,9 @@ export default Vue.extend({
200224
rounded: true,
201225
swipeAble: true,
202226
isFullScreen: false,
203-
overlayColorSelect: "#0000004D"
227+
overlayColorSelect: "#0000004D",
228+
backgroundScrollable: false,
229+
backgroundClickable: false,
204230
};
205231
},
206232
components: {

package-lock.json

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

src/vue-bottom-sheet.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
]"
1111
v-on="handlers"
1212
ref="bottomSheet"
13+
:style="{ 'pointer-events': backgroundClickable && clickToClose == false ? 'none' : 'all' }"
1314
>
1415
<div v-if="overlay" class="bottom-sheet__backdrop" :style="{ 'background': overlayColor }" />
1516
<div
16-
:style="[{ bottom: cardP+'px', maxWidth: maxWidth, maxHeight: maxHeight },{'height':isFullScreen ? '100%' : 'auto'}]"
17+
:style="[{ bottom: cardP+'px', maxWidth: maxWidth, maxHeight: maxHeight },{'height':isFullScreen ? '100%' : 'auto'},{'pointer-events': 'all'}]"
1718
:class="[
1819
'bottom-sheet__card',
1920
{ stripe: stripe, square: !rounded },
@@ -98,6 +99,14 @@ export default {
9899
type: String,
99100
default: "#0000004D"
100101
},
102+
backgroundScrollable: {
103+
type: Boolean,
104+
default: false
105+
},
106+
backgroundClickable: {
107+
type: Boolean,
108+
default: false
109+
}
101110
},
102111
methods: {
103112
isIphone() {
@@ -170,7 +179,11 @@ export default {
170179
this.init().then(() => {
171180
this.opened = true;
172181
this.cardP = 0;
173-
document.body.style.overflow = "hidden";
182+
183+
if (!this.$props.backgroundScrollable) {
184+
document.body.style.overflow = "hidden";
185+
}
186+
174187
this.$emit("opened");
175188
});
176189
},

0 commit comments

Comments
 (0)