Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Vue 3 (and Nuxt 3) support? #31

Open
eMeRiKa13 opened this issue Feb 7, 2022 · 4 comments
Open

Vue 3 (and Nuxt 3) support? #31

eMeRiKa13 opened this issue Feb 7, 2022 · 4 comments

Comments

@eMeRiKa13
Copy link

Hi,

Is-this plugin working for Vue 3 (with Nuxt 3)?

It's exactly what I'm looking for.

Thanks

@eMeRiKa13
Copy link
Author

I tried and unfortunately not

@thpngj
Copy link

thpngj commented Apr 3, 2022

this is Vue3

`

<script setup> import {computed} from "vue"; const props = defineProps({ barStyle: Object, duration: {type: String, default: "12s"}, direction: {type: String, default: "normal"},// delay: {type: String, default: "0s"} }) const customStyle = computed(()=>{ return Object.assign({}, props.barStyle, { "animation-duration": props.duration, "animation-direction": props.direction, "animation-delay": props.delay }) }) </script> <style scoped> @Keyframes moveSlideshow { 100% { transform: translateX(-50%); } } .ap-container { width: 100%; overflow: hidden; } .ap-element { transform: translate3d(0, 0, 0); /* Hey browser, please use my GPU */ position: relative; overflow: hidden; animation-name: moveSlideshow; animation-iteration-count: infinite; animation-timing-function: linear; display: flex; width: max-content; min-width: 200%; } .ap-bar { width: 50%; } </style>`

@markus-gx
Copy link

markus-gx commented May 6, 2022

I tried and unfortunately not

Create a component with this code and it works (Tried in Nuxt 3 rc.1)

<script>
import { h, defineComponent } from 'vue';
export default defineComponent({
  props: {
    barStyle: Object,
    duration: {
      type: String,
      default: '12s',
    },
    direction: {
      type: String,
      default: 'normal',
    },
    delay: {
      type: String,
      default: '0s',
    },
    paused: {
      type: Boolean,
      default: false,
    },
  },
  computed: {
    customStyle() {
      return {
        ...this.barStyle,
        'animation-duration': this.duration,
        'animation-direction': this.direction,
        'animation-delay': this.delay,
        'animation-play-state': this.paused ? 'paused' : 'running',
      };
    },
  },
  render() {
    const bar = h('div', { class: 'vifnslb-bar' }, this.$slots.default());
    const slider = h(
      'div',
      { class: ['vifnslb-element'], style: this.customStyle },
      [bar, bar]
    );
    return h('div', { class: ['vifnslb-container'] }, [slider]);
  },
});
</script>

<style scoped>
@keyframes moveSlideshow {
  100% {
    transform: translateX(-50%);
  }
}
.vifnslb-container {
  width: 100%;
  overflow: hidden;
}
.vifnslb-element {
  transform: translate3d(0, 0, 0); /* Hey browser, please use my GPU */
  position: relative;
  overflow: hidden;
  animation-name: moveSlideshow;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  display: flex;
  width: max-content;
  min-width: 200%;
}
.vifnslb-bar {
  width: 50%;
}
</style>

@Rotinx
Copy link

Rotinx commented Nov 5, 2022

Composition TS file version

<template>
  <render/>
</template>
<script setup lang="ts">
import {computed, h, defineProps, useSlots} from "vue";

const slots = useSlots()

const props = defineProps<{
  barStyle: Object,
  duration?: {
    type: string
  },
  direction?: {
    type: string
  },
  delay?: {
    type: string
  },
  paused? : {
    type: boolean
  }
}>()

const customStyle = computed(() => {
  return {
    ...props.barStyle,
    'animation-duration': props.duration ? props.duration.type : '12s',
    'animation-direction': props.direction ? props.direction.type : 'normal',
    'animation-delay': props.delay ? props.delay.type : '0s',
    'animation-play-state' : (props.paused && props.paused.type) ? 'paused' : 'running'
  }
})

const render = () => {
  // @ts-ignore
  const bar = h('div', { class: 'vifnslb-bar' }, slots.default())
  const slider = h('div', { class: 'vifnslb-element', style: customStyle.value }, [bar, bar])
  return h('div', { class: 'vifnslb-container' }, [slider])
}
</script>

<style>
@keyframes moveSlideshow {
  100% {
    transform: translateX(-50%);
  }
}
.vifnslb-container {
  width: 100%;
  overflow: hidden;
}
.vifnslb-element {
  transform: translate3d(0, 0, 0); /* Hey browser, please use my GPU */
  position: relative;
  overflow: hidden;
  animation-name: moveSlideshow;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  display: flex;
  width: max-content;
  min-width: 200%;
}
.vifnslb-bar {
  width: 50%;
}
</style>

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

No branches or pull requests

4 participants