Shuffle icon indicating copy to clipboard operation
Shuffle copied to clipboard

isCentered option does not always work as expected

Open OceanITs opened this issue 7 years ago • 5 comments

[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); }

OceanITs avatar Oct 26 '17 01:10 OceanITs

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?

vestride avatar Oct 26 '17 02:10 vestride

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);

OceanITs avatar Oct 26 '17 16:10 OceanITs

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?

superjunky avatar Dec 04 '17 17:12 superjunky

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.

vestride avatar Dec 04 '17 18:12 vestride

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

superjunky avatar Dec 04 '17 19:12 superjunky