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

fix rounding errors in responsive carousel #678

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix rounding errors in responsive carousel #678

wants to merge 1 commit into from

Conversation

albell
Copy link
Contributor

@albell albell commented Mar 16, 2015

Clipping the edge of a crucial slide in a responsive carousel looks really bad. This currently happens way too easily. Two fixes:

  1. Browsers (incl Chrome) don't seem to resolve all rounding-related layout issues until load. Listen for that as well as resize.

  2. Don't round slide CSS widths up to the nearest integer. This causes the last visible slide in the carousel to overflow the container. All modern browsers have used subpixel rendering for a while now. See column 4 in this chart:

http://cruft.io/posts/percentage-calculations-in-ie/

Clipping the edge of a crucial slide in a responsive carousel looks really bad. This currently happens way too easily. Two fixes:

1) Browsers don't seem to resolve all rounding-related layout issues until load. Listen for that as well as resize.

2) Don't round slide dimension up to the nearest integer. This causes overflow. All modern browsers have used subpixel rendering for a while now. See column 4 in this chart:

http://cruft.io/posts/percentage-calculations-in-ie/
@@ -143,7 +143,7 @@ $.fn.cycle.transitions.carousel = {
var prepareDimensions = this.prepareDimensions;

// throttle resize event
$(window).on( 'resize', resizeThrottle);
$(window).on( 'load resize', resizeThrottle);

opts._carouselResizeThrottle = resizeThrottle;
onResize();
Copy link

Choose a reason for hiding this comment

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

This should be removed to prevent onResize from being called twice. It will be called on window.load so we no longer need it here.

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.

2 participants