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

Flickity still hidden after displaying #150

Closed
NasuhGencaslan opened this Issue May 30, 2015 · 3 comments

Comments

3 participants
@NasuhGencaslan

NasuhGencaslan commented May 30, 2015

Hi, maybe this is not total related to flickity but I am using Jquery to "display:none to block" on parent main-gallery div. But images are not shown. Onyl shown after resizing the browser and inspect element.

<div id="gnc2"class="row">
  <div class="col s3 offset-s1">

    <div class="thumbnail">
      <img src="galeri/gizemler/1.jpg" alt="Gizemler">
      <div class="caption">
        <h5 class="center-align">Gizemler</h5>
        <p class="center-align">Serideki mitler, gizemler</p>
        <p class="center-align"><a id="nbg2" class="waves-effect waves-light btn">Ateşle</a></p>
      </div>
    </div>

  </div>
</div>

<div id="nbg1">
  <h5 class="center-align">One Piece Gizemler</h5>
  <div class="main-gallery">
    <div class="gallery-cell"><img src="galeri/gizemler/1.jpg"/></div>
    <div class="gallery-cell"><img src="galeri/gizemler/2.jpg"/></div>
    <div class="gallery-cell"><img src="galeri/gizemler/3.jpg"/></div>
  </div>
</div>
$('.main-gallery').flickity({
    // options
    cellAlign: 'left',
    contain: true
  });

$(document).ready(function() {
  $('#nbg2').click(function() {
    $("#gnc2").css("display","none");
    $("#nbg1").css("display","block");
  });
});

@desandro desandro changed the title from Flickity Images shown after resizing the browser to Flickity still hidden after displaying Jun 2, 2015

@desandro

This comment has been minimized.

Member

desandro commented Jun 2, 2015

If Flickity is initialized while hidden, it will need its resize method to be triggered. See demo http://codepen.io/desandro/pen/eNvdoo


For your code, bring the flickity code inside $(document).ready()

$(document).ready(function() {
  var $mainGallery = $('.main-gallery').flickity({
    // options
    cellAlign: 'left',
    contain: true
  });


  $('#nbg2').click(function() {
    $("#gnc2").css("display","none");
    $("#nbg1").css("display","block");
    // resize flickity after being shown
    $mainGallery.flickity('resize');
  });
});

@desandro desandro added the How do I? label Jun 2, 2015

@desandro

This comment has been minimized.

Member

desandro commented Jun 2, 2015

Closing this issue as a duplicate of #65. See solution there

@desandro desandro closed this Jun 2, 2015

@desandro desandro added the duplicate label Jun 2, 2015

@JacobGPD

This comment has been minimized.

JacobGPD commented Apr 11, 2018

Hi @desandro,

I'm having the same issue here. Can you please explain further where to paste this:

$(document).ready(function() {
var $mainGallery = $('.main-gallery').flickity({
// options
cellAlign: 'left',
contain: true
});

$('#nbg2').click(function() {
$("#gnc2").css("display","none");
$("#nbg1").css("display","block");
// resize flickity after being shown
$mainGallery.flickity('resize');
});
});

Thanks!

@metafizzy metafizzy locked and limited conversation to collaborators Apr 11, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.