Spacing option not working on iOS #189

Closed
daveachuk opened this Issue Apr 26, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@daveachuk

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

This comment has been minimized.

Show comment
Hide comment
@pisi

pisi May 17, 2013

Owner

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.

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

This comment has been minimized.

Show comment
Hide comment
@pisi

pisi May 17, 2013

Owner

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!

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 Jun 3, 2013

@pisi

This comment has been minimized.

Show comment
Hide comment
@pisi

pisi Nov 5, 2013

Owner

Released today as part of v1.3.0

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