loryjs / lory

☀ Touch enabled minimalistic slider written in vanilla JavaScript.
http://loryjs.github.io/lory/
MIT License
2.28k stars 244 forks source link

Centre mode #460

Open SukhKalsi opened 7 years ago

SukhKalsi commented 7 years ago

Hello

How can i configure Lory to centre the slide?

For example, Slick has an option called 'centerMode' which enables me to show one slide only but with mini previews of the previous and next slide.

Thanks

nstanard commented 7 years ago

You would probably want to use variable width mode.

SukhKalsi commented 7 years ago

Hmm not sure how that helps? Lory seems to always position the slides to the hard edge (either left or right depending on direction)

nstanard commented 7 years ago

Seems like you realize that this isn't an option currently ;)

SukhKalsi commented 7 years ago

Ha I guess so! So I suppose this is a feature request. What is the effort level required to get this in?

curtisblackwell commented 7 years ago

Any plans for this yet?

curtisblackwell commented 7 years ago

I figured out a way to accomplish this using CSS.

Let's say you want 3 slides displayed at a time. Each slide is 200px, and there's a 20px gutter b/w slides.

$slideWidth: 200px;
$slideGutter: 20px;

.frame {
  width: ($slideWidth * 3) + ($slideGutter * 2);
}

.slide {
  transform: translateX($slideWidth + $slideGutter);
  width: $slideWidth;

  + .slide {
    margin-left: $slideGutter;
  }
}
lory(slider, { infinite: 3 });

It's not ideal, b/c it doesn't work w/o infinite (can't focus on last two), but it'll do for now on this project.

Sandstedt commented 7 years ago

I manage to use some of you css @curtisblackwell but solved it a little different.

.slide {
  width: 60vw;
  transform: translateX(33.333%); // center slide
  margin-left:10px;
  margin-right:10px;
}
octojoerg commented 6 years ago

Any way to center slides if you don't know how much slides you have?

nishantuie commented 5 years ago

If you are ok to update lory.js code, I have updated the code to add centerMode functionality.

I have added an option for centerMode with

  1. the first slide center align
  2. the first slide left align

https://github.com/nishantuie/lory/tree/feature/center-mode

PR Raised: https://github.com/loryjs/lory/pull/763

Ankitpatel08 commented 5 years ago

If you are ok to update lory.js code, I have updated the code to add centerMode functionality.

I have added an option for centerMode with

  1. the first slide center align
  2. the first slide left align

https://github.com/nishantuie/lory/tree/feature/center-mode

PR Raised: #763

This fix works with all type of slides like variable width and in all breakpoints. Thank You! (y)

mikailbayram commented 4 years ago

Any update on this?

nishantuie commented 4 years ago

Any update on this?

@mikailbayram please take a look at PR https://github.com/loryjs/lory/pull/763

@Saturate has reviewed and approved PR, he shall merge feature branch to master. Meanwhile, feel free to get code from https://github.com/nishantuie/lory/tree/feature/center-mode

Hope this helps.

mikailbayram commented 4 years ago

@nishantuie thanks for the update!

GiancarlosIO commented 4 years ago

:eyes: