Git Product home page Git Product logo

Comments (15)

setianke avatar setianke commented on August 26, 2024 12

@exdeniz

I achieved your desired behavior with simple CSS:

Give the keen-slider div overflow visible and wrap the slider in a div with padding as desired:

https://codesandbox.io/s/new-frost-xkkm7?fontsize=14&hidenavigation=1&theme=dark

from keen-slider.

rcbyr avatar rcbyr commented on August 26, 2024 4

Hello @exdeniz

okay, I get it now. I'll put it on my list, but I can't tell you when I'm gonna do it. There are some more important features for me right now that need some time. But I hope to give you this feature soon.

from keen-slider.

liqueflies avatar liqueflies commented on August 26, 2024 1

Not want to reopen this issue but in the new keen-slider the origin parameter is just a percentage on the viewport.
Is it possible to specify in pixel directly?

from keen-slider.

rcbyr avatar rcbyr commented on August 26, 2024

Hey @exdeniz

I think to achieve this behavior, it would be easier to use the slider with these options:

new KeenSlider("#slider", {
  slidesPerView: 2,
  centered: true,
})

Do you agree?

from keen-slider.

exdeniz avatar exdeniz commented on August 26, 2024

No, it's similar behavior, but a little wrong.
I make the first slide offset equal to the global padding container.
I drew a quick layout to explain the idea.

Center slides:

Slider with offset, start position.

Slider with offset, second slide position.

Slider with offset, last slide postion.

from keen-slider.

exdeniz avatar exdeniz commented on August 26, 2024

Hello @exdeniz

okay, I get it now. I'll put it on my list, but I can't tell you when I'm gonna do it. There are some more important features for me right now that need some time. But I hope to give you this feature soon.

Thank you, I understand that there are more important things, such as width:auto for slides. I just hope to find a light version of swiper.js for my projects.

from keen-slider.

rcbyr avatar rcbyr commented on August 26, 2024

@exdeniz

I think I saw this project on reddit. https://github.com/joe223/tiny-swiper

Maybe, you should give it a try, if you look for a swiperjs-like lib.

from keen-slider.

sergiodebei avatar sergiodebei commented on August 26, 2024

What about adding an extra empty div as last slide? It might be a quick solution

from keen-slider.

exdeniz avatar exdeniz commented on August 26, 2024

What about adding an extra empty div as last slide? It might be a quick solution
Adding extra slides makes it bad for navigation.

from keen-slider.

dhananjaygandhi avatar dhananjaygandhi commented on August 26, 2024

What about one side offset. Like
First Slide
Screenshot 2021-05-29 at 10 51 34 AM

Middle
Screenshot 2021-05-29 at 10 52 34 AM

Last
Screenshot 2021-05-29 at 10 51 56 AM

from keen-slider.

rcbyr avatar rcbyr commented on August 26, 2024

In the new version of keen-slider you can configure the sizes, origins and spacing of each slide separately. So, I think this issue can be closed.

from keen-slider.

madebyfabian avatar madebyfabian commented on August 26, 2024

@liqueflies I had the same thing. You can specify slides.perView = 'auto' and then give every slide element a min-width and max-width. I used 75vw, but you can also set pixels.

from keen-slider.

rcbyr avatar rcbyr commented on August 26, 2024

Hey @liqueflies

would it be helpful when the origin parameter can be a function?

from keen-slider.

ArekBartnik avatar ArekBartnik commented on August 26, 2024

@rcbyr if the origin became a function would it be possible to pass to it if it is a "looped" slide?
I'm working on a slider in which the first slide is aligned to left and the rest is centered but if I set origin to 0 then all "first" slides will be rendered with this origin.

from keen-slider.

timfuhrmann avatar timfuhrmann commented on August 26, 2024

@rcbyr If origin could be a function and container size is provided, one could transform the px value into the value related to the container size. Anyways, unfortunately this does not help to achieve inline padding, as the last item would scroll to padding left. Happy to dig in and create a pull request.

Following @setianke's approach does not work for some cases where loop is enabled, since the extra padding is not added to the slider's container size.

from keen-slider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.