Jumping indexes too far with `next`
See original GitHub issueHi there,
I’m experiencing an issue with a slider of 6 items where 4 are visible with perView
. It seems that after moving right using next
twice, to the last item, the track.details.abs
goes to 2 (as it should), but then jumps to 4 for some reason. This causes attempting to move back using prev
to go to the index 3, which doesn’t work.
I’m using it in Vue/Nuxt, as so:
<template>
<section>
<div ref="carouselWrapper">
<Card
v-for="item of items"
:key="item.name"
class="keen-slider__slide"
v-bind="item"
/>
</div>
<button @click="slider.prev()">prev</button>
<button @click="slider.next()">next</button>
</section>
</template>
<script>
import {
ref,
onMounted,
onBeforeUnmount,
} from '@nuxtjs/composition-api'
import KeenSlider from 'keen-slider'
export default {
name: 'MyCarousel',
props: {
items: {
type: Array,
required: true,
},
},
setup(props) {
const carouselWrapper = ref(null)
const slider = ref()
onMounted(() => {
slider.value = new KeenSlider(carouselWrapper.value, {
slides: {
perView: 4,
spacing: 16,
},
created: () => {
setTimeout(() => {
// update immediately after mount
slider.value && slider.value.update()
}, 0)
},
})
})
onBeforeUnmount(() => {
if (slider.value) slider.value.destroy()
})
return {
carouselWrapper,
slider,
}
},
}
</script>
Am I doing something foolish? Or could this be a bug?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Is there a way to jump ahead to a later index in the loop?
I'm working on an experiment in which I need to dynamically be able to repeat certain trials. I've read that jumping back is...
Read more >List indexes - If too big go back to the beginning of the list
But my problem is that how could I tell python that if the index number goes up too high, it should start counting...
Read more >Understanding ClickHouse Data Skipping Indexes
In circumstances where querying a table is too expensive unless a skip index is used, using this setting with one or more index...
Read more >How to adjust bike gears | How to index gears and fix shifting ...
In this easy-to-follow guide, we talk through how to index gears, setting derailleur limits and replacing a hanger.
Read more >Minimum number of jumps to reach end | Set 2 (O(n) solution)
Next subarray end index. // and so far calculated sub. // array max step cover value. subArrEndIndex = arr[firstHalfMaxStepIndex];.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
issue can be easily reproduced by setting high value for spacing.
Seems to be fixed by the PR from ponciusz.