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

use jQuery css function instead of width #1301

Merged
merged 2 commits into from
May 12, 2015

Conversation

ethanclevenger91
Copy link
Contributor

Broken: http://codepen.io/ethanclevenger91/pen/MwwoqJ
Fixed: http://codepen.io/ethanclevenger91/pen/EjjXdb

Could honestly be a jQuery thing, but in the buildRows function:

.width((100 / _.options.slidesPerRow) + "%")

adds padding to the value written. (100 / _.options.slidesPerRow) + '%' may result in 33.33...%, but if you have padding:5px, you can log right after that line the value and see that it's been set to 43.33...% - 10% is added (twice the padding as a percentage). Swapping that line for:

.css('width', (100 / _.options.slidesPerRow) + "%") resolves the issue.

Didn't see build instruction - let me know if I need to take care of that

@@ -549,7 +549,7 @@
};
_.$slider.html(newSlides);
_.$slider.children().children().children()
.width((100 / _.options.slidesPerRow) + "%")
.css('width', (100 / _.options.slidesPerRow) + "%")
.css({'display': 'inline-block'});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually do

_.$slider.children().children().children()
  .css({
    'width': (100 / _.options.slidesPerRow) + "%",
    'display': 'inline-block'
  });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, forgot the syntax when I first wrote it. Updated.

@simeydotme
Copy link
Collaborator

Thanks, @ethanclevenger91, it looks good!

simeydotme added a commit that referenced this pull request May 12, 2015
@simeydotme simeydotme merged commit 5f2aa75 into kenwheeler:master May 12, 2015
@ethanclevenger91 ethanclevenger91 deleted the padding-width-grid-fix branch October 22, 2015 14:31
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

Successfully merging this pull request may close these issues.

3 participants