Skip to content
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

Add class to first and last item in row #90

Closed
generatepress opened this issue Nov 2, 2015 · 3 comments
Closed

Add class to first and last item in row #90

generatepress opened this issue Nov 2, 2015 · 3 comments

Comments

@generatepress
Copy link

Love this plugin - thanks so much for creating it.

Is it possible to tap into the code and add a class to the first and last element in each row? Would much rather use the power of this plugin to do so than write something new.

Thanks again!

@jorrit
Copy link
Contributor

jorrit commented Nov 8, 2015

Wild idea: spin off row detection into a separate jQuery plugin.

@liabru
Copy link
Owner

liabru commented Nov 9, 2015

Actually I recently exposed the _rows function for unit testing purposes.

If you copy the latest master, you can now just use it like this:

var rows = $.fn.matchHeight._rows($('.item'));

$.each(rows, function(i, row) {
    console.log(row);
    row.first().addClass('first');
    row.last().addClass('last');
});

Here is an example:
https://jsfiddle.net/liabru/6qpr1n02/

@jorrit I thought about doing that previously actually... Now I guess you don't have to!

@generatepress
Copy link
Author

** slow clap **

Works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants