Issue with height in first time load
hello, i love this slider so much, easy to use and have a pretty nice design too but my slider height have some issue if you are the first time visitor (mean height issue will gone if u refresh the page)
here take a look https://surgatekno.com/spek-game/spesifikasi-game-the-division-2/
and this image for example https://i.imgur.com/Vn2nzuP.jpg
i load my .css and .js on
i dunno how can encountered this issue (even u load my site in front page, then u visit that page, it still have height issue, unless you refresh the page then everything will be normal) https://surgatekno.com/ my front page pleasehelp.
Sounds like an imagesLoaded: true fix
Sounds like an imagesLoaded: true fix
its work like a charm, thank you but next problem is the image between the slider goes smaller https://i.imgur.com/mZCJxD9.jpg its getting smaller in each slide of image
edit---- so i configure it out, it was my image size.. not same but how to force the image to show the same height ?? (also my dots in not centered as well)
Same here, imageLoaded: true didn't work.

@surgatekno See the demo here: https://codepen.io/desandro/pen/MYQWEe
@surgatekno See the demo here: https://codepen.io/desandro/pen/MYQWEe
thank you, its work well
some case's this issue still appear, Despite of adding : {imagesLoaded: true} , I fix fix the issue by giving a css width value in the parent div. Hope that would be helpful.
In some cases this issue still appears, Despite of adding {imagesLoaded: true},
The Fix is, imagesLoaded requires the flickity-imagesloaded package. It already is included with flickity.pkgd.js, but not with Flickity as a stand-alone package. If you are using Webpack or RequireJS without flickity.pkgd.js, you need to install and require flickity-imagesloaded separately.
npm install flickity npm install flickity-imagesloaded
var Flickity = require('flickity');
require('flickity-imagesloaded');
var flkty = new Flickity( '.carousel', {
imagesLoaded: true
});
For Angular 4 to 8:
npm install flickity npm install flickity-imagesloaded npm install @types/node
tsconfig.app.json: ( add "types": ["node"] )
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["node"]
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"src/test.ts",
"src/**/*.spec.ts"
]
}
import { Component, OnInit, Inject, AfterViewInit } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import * as Flickity from 'flickity';
require('flickity-imagesloaded');
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit, AfterViewInit {
constructor(@Inject(DOCUMENT) private document: Document) { }
ngOnInit() {
}
ngAfterViewInit() {
this.initializeFlickitySlider();
}
initializeFlickitySlider() {
var elem = this.document.querySelector('.main-carousel');
new Flickity(elem, {
autoPlay: true,
imagesLoaded: true,
wrapAround: true
})
}
}
<div class="main-carousel">
<div class="carousel-cell col-xl-3 col-lg-4 col-md-5 col-9 pb-1">
<div class="card">
<div class="card-body">
<!---->
</div>
</div>
</div>
</div>
For more information, https://flickity.metafizzy.co/extras.html#module-loaders
Hope that would be helpful.
$(window).on('load', function(){ //create flickity }); has given me a lot of success in the past, without including another library.
Rather that using window load to initialize Flickity, you can use it to trigger resize, so Flickity gets initialized soon, then resizes after all media has been loaded.
let $carousel = $('.carousel').flickity({});
$(window).load( function() {
$carousel.flickity('resize');
});
Ah yes, thank you!
I use resize function in my vue project and worked for me in template section
<flickity ref="flickity" :options="flickityOptions">
// show something here <3
</flickity>
in data section
data() {
return {
flickityOptions: {
imagesLoaded: true,
}
}
}
in mounted section
mounted() {
this.$nextTick(() => {
let _this = this;
document.addEventListener("readystatechange", event => {
if (event.target.readyState === "complete") {
_this.$refs.flickity.resize();
}
});
});
}
Adding a min-height: 100%; width:100%; to my gallery cells solved the problem.