Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prop for initial height #39

Open
lyqht opened this issue Aug 12, 2023 · 2 comments
Open

Prop for initial height #39

lyqht opened this issue Aug 12, 2023 · 2 comments

Comments

@lyqht
Copy link

lyqht commented Aug 12, 2023

Right now we have a prop for maxHeight, but it will be nice if this component has props which are similar to native bottom sheet component or a simple prop for setting initial height in addition to the max height.

For example, i would like the bottom sheet to start off short first at 90px, then users can drag it to a max height of 80% of the viewport height.

Initial height

CleanShot 2023-08-12 at 00 50 18@2x

Max height

CleanShot 2023-08-12 at 00 51 47@2x

@laurablum
Copy link

@lyqht

I have had the same issue and created a ugly workaround for this.
Maybe this can help you out in the meantime.

<template>
  <vue-bottom-sheet
      ref="bottomSheet"
      class="pb-16"
      :can-swipe="false"
  >
    <div>
      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
      dolore
      magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
      gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
      sadipscing
      elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
      eos
      et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
      dolor
      sit amet.
    </div>
  </vue-bottom-sheet>
</template>
<script setup>
import VueBottomSheet from "@webzlodimir/vue-bottom-sheet";

let isFullSize = false;

const toggleHeight = () => {
  const height = isFullSize ? 50 : 90;

  const element = document.getElementsByClassName("bottom-sheet__content")?.[0];
  if (element) {
    element.setAttribute("style", `height: ${height}vh !important`);
    isFullSize = !isFullSize;
  }
}

const open = () => {
  this.$refs.bottomSheet.open();

  const header = document.getElementsByClassName("bottom-sheet__header")?.[0];
  header?.addEventListener("mousedown", () => toggleHeight());
}

defineExpose({
  open,
});


</script>

<style>

.bottom-sheet__content {
  height: 50vh !important;
}

</style>

I wrapped this in a own component and you have to call the open method from the higher order component.

This is super ugly and I really unlike this, so it would be very nice if this could be fixed in a future release.

@chrisk8er
Copy link

@lyqht

I have had the same issue and created a ugly workaround for this. Maybe this can help you out in the meantime.

<template>
  <vue-bottom-sheet
      ref="bottomSheet"
      class="pb-16"
      :can-swipe="false"
  >
    <div>
      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
      dolore
      magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
      gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
      sadipscing
      elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
      eos
      et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
      dolor
      sit amet.
    </div>
  </vue-bottom-sheet>
</template>
<script setup>
import VueBottomSheet from "@webzlodimir/vue-bottom-sheet";

let isFullSize = false;

const toggleHeight = () => {
  const height = isFullSize ? 50 : 90;

  const element = document.getElementsByClassName("bottom-sheet__content")?.[0];
  if (element) {
    element.setAttribute("style", `height: ${height}vh !important`);
    isFullSize = !isFullSize;
  }
}

const open = () => {
  this.$refs.bottomSheet.open();

  const header = document.getElementsByClassName("bottom-sheet__header")?.[0];
  header?.addEventListener("mousedown", () => toggleHeight());
}

defineExpose({
  open,
});


</script>

<style>

.bottom-sheet__content {
  height: 50vh !important;
}

</style>

I wrapped this in a own component and you have to call the open method from the higher order component.

This is super ugly and I really unlike this, so it would be very nice if this could be fixed in a future release.

add a CSS transition and it will transition smoothly.

.bottom-sheet__content {
    color: #000;
    height: 20vh !important;
    transition: height 0.3s ease-in-out;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants