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

Spacing option not working on iOS #189

Closed
daveadotdev opened this issue Apr 26, 2013 · 3 comments
Closed

Spacing option not working on iOS #189

daveadotdev opened this issue Apr 26, 2013 · 3 comments
Assignees
Milestone

Comments

@daveadotdev
Copy link

Ok, I now officially feel bad for submitting 3 issues in 3 days >.> I should probably figure out how to do Pull Requests so I can make things easier in the future for people like you!

Here's another one having to do with the 'spacing' option.

Basically, if you set spacing=2 for example, on mobile (aka touchy), the spacing is not applied. The line in question is related to this mobile customization (starting on line 879):

if (touchy){
  // workaround for downsizing-sprites-bug-in-iPhoneOS inspired by Katrin Ackermann
  css(___+dot(klass), { WebkitBackgroundSize: get(_images_).length
    ? !stitched ? undefined : px(stitched)+___+px(space.y)
    : stitched && px(stitched)+___+px((space.y + opt.spacing) * rows - opt.spacing)
    || px(space.x * opt.footage)+___+px(space.y * get(_rows_) * rows * (opt.directional? 2:1))
  });

This basically forces the mobile browser to scale the background image explicitly to the desired size. However, the spacing option is not included in the calculation for the x size, so in my case it was being set to a size that was opt.footage*opt.spacing too narrow. The fix (on the last line):

if (touchy){
  // workaround for downsizing-sprites-bug-in-iPhoneOS inspired by Katrin Ackermann
  css(___+dot(klass), { WebkitBackgroundSize: get(_images_).length
    ? !stitched ? undefined : px(stitched)+___+px(space.y)
    : stitched && px(stitched)+___+px((space.y + opt.spacing) * rows - opt.spacing)
    || px((space.x + opt.spacing) * opt.footage)+___+px(space.y * get(_rows_) * rows * (opt.directional? 2:1))
  });
@pisi
Copy link
Owner

pisi commented May 17, 2013

I should probably figure out how to do Pull Requests so I can make things easier in the future for people like you!

👍 My words! This fix you nearly nailed. It just misses - opt.spacing for the missing last spacing gap on the far right of the sprite.

|| px((space.x + opt.spacing) * opt.footage - opt.spacing)+___+px(space.y * get(_rows_) * rows * (opt.directional? 2:1))

Nice one! Thanks :) Frankly, this one is the most terrifying piece of code in Reel, so I very appreciate second pair of eyes.

@pisi
Copy link
Owner

pisi commented May 17, 2013

And of course the Y side needed the same treatment.

@daveachuk Can you please test it on your use case? Patched code is in the development branch. Thanks!

@ghost ghost assigned pisi May 17, 2013
@pisi pisi closed this as completed Jun 3, 2013
@pisi
Copy link
Owner

pisi commented Nov 5, 2013

Released today as part of v1.3.0

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

No branches or pull requests

2 participants