Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Centering elements in isotope

Community Beginner ,
Jul 30, 2016 Jul 30, 2016

Hello everyone and I hope you're doing well. I am using Isotope and below you can see the JS that I've wrote. The thing is that I find it impossible to center -li- elements which they are the Isotope elements. By centering I mean the image below. I've managed to center the whole Isotope to the screen but I need the elements to be centered too and not just float to the left side.

Let's start with my script code:

<script>

$(document).ready(function(e) {

$(".ullist li").addClass('element-item'); });

</script>

<script>

$(document).ready(function(e) {

// external js: isotope.pkgd.js

// init Isotope

var $grid = $('.grid').isotope({

  itemSelector: '.element-item',

  //layoutMode: 'fitRows',});

//$('.grid').isotope({ layoutMode : 'fitRows' });

// filter functions

var filterFns = {

  // show if number is greater than 50

  numberGreaterThan50: function() {

    var number = $(this).find('.number').text();

    return parseInt( number, 10 ) > 50;},

  // show if name ends with -ium

  ium: function() {

    var name = $(this).find('.name').text();

    return name.match( /ium$/ );}

};

// bind filter button click

$('#filters').on( 'click', 'a', function() {

  var filterValue = $( this ).attr('data-filter');

  // use filterFn if matches value

  filterValue = filterFns[ filterValue ] || filterValue;

  $grid.isotope({ filter: filterValue });

});

// change is-checked class on buttons

$('.secmenu ul a').each( function( i, buttonGroup ) {

  var $buttonGroup = $( buttonGroup );

  $buttonGroup.on( 'click', 'a', function() {

    $buttonGroup.find('.is-checked').removeClass('is-checked');

    $( this ).addClass('is-checked');

  });

});});

</script>

<script>

$(function(){var $container = $('.grid'),

      $body = $('body'),

      colW = 20,

      columns = null;

  $container.isotope({

    // disable window resizing

    resizable: true,

    masonry: {

      columnWidth: colW,

        isFitWidth: true

    }

  });

  $(window).smartresize(function(){

    // check if columns has changed

    var currentColumns = Math.floor( ( $body.width() -10 ) / colW );

    if ( currentColumns !== columns ) {

      // set new column count

      columns = currentColumns;

      // apply width to container manually, then trigger relayout

      $container.width( columns * colW )

        .isotope('reLayout');

    }}).smartresize(); // trigger resize to set container width

});

</script>

Basic HTML structure:

  <ul class="ullist grid">
<li> ... </li>
<li> ... </li>
<li> ... </li>
<li> ... </li>
  
</ul>

Isotope works pretty good with no issues (as for now). This is my current layout:

xUuw5.jpg

And this is the desirable layout.

FBxcu.jpg

I even checked here and tried to use David DeSandro's repository but with no success. So please guys can you help me here to achieve the layout above? Thank you all in advance.

jQuery isotope centering - Stack Overflow

TOPICS
Acrobat SDK and JavaScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Why did you post this in the forum for Acrobat JavaScript?

Your code will not work in Acrobat.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2016 Jul 30, 2016

I thought  this was a forum for general questions about javascript. I didn't know it was only for Acrobat. Anyway I would be grateful if you could help me with this one.  Thank you in advance.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

We can't.

The two JavaScript implementations for the browser vs. Acrobat are too different. Yes, the core language is the same, but the application specific extensions are completely different. You need somebody who is familiar with browser level JavaScript and Isotope. Nobody else can help you. Things like JQuery or Isotope do not run inside Acrobat.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2016 Jul 30, 2016

Where should I post this question in adobe forums? Which category?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2016 Jul 31, 2016
LATEST

Is this related to a specific Adobe product? If not, try Stack Overflow .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines