Offset Tile - Wrap around delayed loading
Hey David,
I'm trying to offset the tiles by 200px by adding transform: translateX(-200px);. As you scroll through you'll notice that the end tiles load in with a slight delay.
Is there someway that we can load in 2 tiles at the end or beginning to prevent this? Perhaps there is an easier solution to this issue?
https://codepen.io/MarioD/pen/vOWjar
Thanks, Mario
I'm trying to offset the tiles by 200px
Can you explain what you're trying to achieve? Are you trying to align the cells a certain way? I think the best way to resolve this issue is to find a solution here.
Hey David,
We are trying to align the first tile to the edge of our website container, where the titles appear.
Here's an example.
https://codepen.io/MarioD/pen/vOWjar
Thanks for the demo! I think we can hack it. See http://codepen.io/desandro/pen/waPXRz
We have to overwrite how a Cell's .target works. We want it to be the left edge of the cell.
Flickity.Cell.prototype.setDefaultTarget = function() {
var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
this.target = this.x + this.size[ marginProperty ];
};
Next, we set cellAlign to a decimal that represents the space between the header element and the left edge
var leftOffset = ( $headingWrapper.parent().innerWidth() - $headingWrapper.width() ) / 2;
var $gallery = $('.gallery');
$gallery.flickity({
cellAlign: leftOffset / $gallery.innerWidth(),
wrapAround: true
});
That did the trick, thanks!
For anyone else that wants to achieve this, it seems we should now be overriding Flickity.Cell.prototype.updateTarget instead of setDefaultTarget (the latter is getting deprecated). However, i couldn't get this behavior with the suggested tweaks, so downgraded my version of flickity to 1.1.
Thanks for that hack, @desandro, exactly what I needed! 😊 Since it really doesn't seem to work with the latest versions any more, is there any chance for an updated hack?