Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isCentered option does not always work as expected #191

Open
OceanITs opened this issue Oct 26, 2017 · 5 comments
Open

isCentered option does not always work as expected #191

OceanITs opened this issue Oct 26, 2017 · 5 comments
Labels

Comments

@OceanITs
Copy link

[css]
.column:nth-child(1) {
height: 200px !important;
}
[js]
isCentered: true,

////////////////
Current version
https://codepen.io/OceanITs/pen/qPexBq

Fixed version
https://codepen.io/OceanITs/pen/EwqQXN

///////////////////
shuffle.js(dist)
line 784 (lastItem.left) must be the same?

///////////////////
Some fix that work for me

comment lines 784,785
before line 780 add {
// add-fix
var lastItem = rowMap[0][rowMap[0].length - 1];
var end = lastItem.left + lastItem.width;
var offset = Math.round((containerWidth - end) / 2);
}

@glen-cheney
Copy link
Owner

Could you fill out the bug report template so that I can understand your issue better please.

Here it is again below:

### Steps to reproduce


### What is Expected?


### What is actually happening?

@OceanITs
Copy link
Author

OceanITs commented Oct 26, 2017

Steps to reproduce

I used this template http://codepen.io/pen?template=qrjOpX

And added this code to better undestand my situation:
[css]

.column:nth-child(1) {
height: 200px !important;
}

[js]

isCentered: true, // new Shuffle

What is Expected?

I expected that all blocks will be centered.
https://codepen.io/OceanITs/pen/EwqQXN (with fix shuffle.js)

What is actually happening?

I got incorrect left position for some blocks.
https://codepen.io/OceanITs/pen/qPexBq (your can just compare)

Why is actually happening?

shuffle.js (dist)

Offset (line 785) must be the same for each block. (Maybe i wrong but it works for my situation)
It not happend for some blocks because lastItem.left (line 784) different in rowMap forEach function.

My Decision

shuffle.js (dist)

Get offset only from first rowMap, and comment others:

comment lines 784,785
before line 780 add

var lastItem = rowMap[0][rowMap[0].length - 1];
var end = lastItem.left + lastItem.width;
var offset = Math.round((containerWidth - end) / 2);

@superjunky
Copy link

superjunky commented Dec 4, 2017

I came across the same problem.
On several rows, the first item on the left have an incorrect horizontal position.

I applied the fix proposed by OceanITs, which seems to work.

Can this be implemented?

@glen-cheney
Copy link
Owner

Yes, there could be a fix implemented, but I'm not focused on Shuffle at the moment.

Pull requests that don't just change the generated dist files are welcome.

@glen-cheney glen-cheney changed the title Incorrect some positions (different block height, first block height < second, isCentered: true) isCentered option does not always work as expected Dec 4, 2017
@superjunky
Copy link

Understood.
I'm not a javascript-wizard.. Perhaps the topicstarter is willing to implement it.

@glen-cheney glen-cheney added the bug label Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants