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

Is there any way I can place arrows outside the slider. I want to place it on extreme left and extreme right on the page. #371

Open
arpagrawal opened this issue Jul 6, 2018 · 8 comments

Comments

@arpagrawal
Copy link

中文用户注意:

  1. 尽量用英文描述你的 issue
  2. 不要把内容堆彻在标题上,逻辑清晰地写在内容区
  3. 贴代码要提前格式化好,有颜色高亮那种,贴文本,不要贴图片
  4. 提问题前,必须仔细阅读 REMADE.md + 在已关闭的问题中寻找与自身相关的问题,90% 的可能它已经被解决
  5. 如果无法做到提一个合格、优秀的问题,则问题会被 close + block

BUG REPORT TEMPLATE

Vue.js version and component version

Reproduction Link

  • A minimal JSBin, JSFiddle, Codepen, or a GitHub repository that can reproduce the bug.
  • You could start with this template: https://jsfiddle.net/39epgLj0/

Steps to reproduce

What is Expected?

What is actually happening?

@r1chm8
Copy link

r1chm8 commented Jul 12, 2018

This is best way I have found of achieving what you're looking for is with the follow code:

In my template

<swiper ref="swiper">
    <swiper-slide></swiper-slide>
    <swiper-slide></swiper-slide>
</swiper>

<a class="swiper-navigation is-previous" @click="swiper.slidePrev()"></a>
<a class="swiper-navigation is-next" @click="swiper.slideNext()"></a>

And then in my javascript

computed: {
    swiper() {
        return this.$refs.swiper.swiper;
    }
}

@AndrewBogdanovTSS
Copy link
Collaborator

Yeah, basically I did the same by wrapping a swiper into an additional outer wrapper like so:

<template>
<div class="swiper-outer-wrapper">
        <div class="swiper" v-swiper:mySwiper="swiperOptions">
            <div class="swiper-wrapper">

                <div class="swiper-slide" :class="itemClass" v-for="(item,index) in items">
                    <img :src="item.image_url">
                </div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
        <div class="swiper-button-prev">
            <button
                    class="swiper-button-default"
                    @click.stop.prevent="slidePrev"
                    aria-label="Previous"
                    type="button"
                    title="Previous">
                <icon class="icon-arrow" name="arrows/arrow-right-md" dir="down" :original="true"></icon>
            </button>
        </div>
        <div class="swiper-button-next">
            <button
                    class="swiper-button-default"
                    aria-label="Next"
                    @click.stop.prevent="slideNext"
                    type="button"
                    title="Next">
                <icon class="icon-arrow" name="arrows/arrow-right-md" :original="true"></icon>
            </button>
        </div>
    </div>
</template>

and then I'm just triggering those slider functions from my methods object. I can't understand why this additional wrapepr is not there by default. Having controls outside the slider itself is very common and cutting it with overflow feels counter-intuitive to me

@AndrewBogdanovTSS
Copy link
Collaborator

I wasn't able to pull pagination out that easily though

@Bobur-kobilov
Copy link

@AndrewBogdanovTSS Hello, Can you explain how u achieved to use controls outside of swiper please?

@AndrewBogdanovTSS
Copy link
Collaborator

@Bobur-kobilov actually I've already explained above. The only thing that can't be pulled out that easily is pagination since it's generated by slider itself but you can override that option by creating your own. A bit tidious, but it'll work

@Bobur-kobilov
Copy link

thank you! i solved it

@sattarsh
Copy link

@AndrewBogdanovTSS hello, can you put your code for achieved to use controls outside of swiper please? because when use above code, slider and navigation button not show inline

@AndrewBogdanovTSS
Copy link
Collaborator

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

5 participants