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

Vue.js version component please #172

Open
CracKerMe opened this issue Nov 10, 2021 · 2 comments
Open

Vue.js version component please #172

CracKerMe opened this issue Nov 10, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@CracKerMe
Copy link

Is your feature request related to a problem? Please describe.
My PM(Product Manager) find that he need a horizontal-scrolling-menu.but our stack is vuejs. have you ever think to publish a vue version plz?

Describe the solution you'd like
vue component needed

thx, waiting for your reply

@asmyshlyaev177
Copy link
Owner

Hi, it will require a lot of time, not sure i will do it.

@asmyshlyaev177 asmyshlyaev177 added the enhancement New feature or request label Nov 23, 2021
@shiva-prasad-reddy
Copy link

shiva-prasad-reddy commented Jan 14, 2023

Is your feature request related to a problem? Please describe. My PM(Product Manager) find that he need a horizontal-scrolling-menu.but our stack is vuejs. have you ever think to publish a vue version plz?

Describe the solution you'd like vue component needed

thx, waiting for your reply

Hey i wrote this in Vue3 using VueUse, Vuetify, it is too much gap, but hoping it will help you.
It is not in good shape but it can be tailoerd to your need.

`<script setup lang="ts">
const { xs } = useVuetify();

const container = ref<HTMLElement | null>(null);
const { x } = useScroll(container);
const scrollWidth = ref(0);
const offsetWidth = ref(0);

if (!xs.value) {
useResizeObserver(container, () => {
if (!container.value) return;
scrollWidth.value = container.value.scrollWidth;
offsetWidth.value = container.value.offsetWidth;
});
}
const leftChevron = computed(() => !xs.value && x.value > 0);
const rightChevron = computed(() => {
if (xs.value) return false;
if (offsetWidth.value >= scrollWidth.value) return false; // no overflow
if (x.value + offsetWidth.value === scrollWidth.value) return false; // scrolled to the end
return true;
});

const widthToScroll = 256 + 16;

const scrollReverse = () => {
container.value.scroll({
top: 0,
left: x.value - (x.value > widthToScroll ? widthToScroll : x.value),
behavior: "smooth",
});
// container.value.scrollLeft -= x.value > 256 ? 256 : x.value;
};

const pixels = computed(() => scrollWidth.value - offsetWidth.value);
const scrollForward = () => {
const gap = pixels.value - x.value;
container.value.scroll({
top: 0,
left: x.value + (gap > widthToScroll ? widthToScroll : gap),
behavior: "smooth",
});
// container.value.scrollLeft += gap >= 256 ? 256 : gap;
};
</script>

    <div class="pl-1 left-chevron">
      <transition name="slide-x-transition">
        <v-btn
          v-show="leftChevron && isHovering"
          icon="i-ic-round-chevron-left"
          size="small"
          color="primary"
          @click="scrollReverse"
        />
      </transition>
    </div>

    <div class="pr-1 right-chevron">
      <transition name="slide-x-reverse-transition">
        <v-btn
          v-show="rightChevron && isHovering"
          icon="i-ic-round-chevron-right"
          size="small"
          color="primary"
          @click="scrollForward"
        />
      </transition>
    </div>
  </div>
</template>
<style> .container { gap: 1rem; }

.container::-webkit-scrollbar {
width: 0px;
height: 0px;
}

.left-chevron {
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
}

.right-chevron {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
}
</style>
`

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

No branches or pull requests

4 participants
@CracKerMe @asmyshlyaev177 @shiva-prasad-reddy and others