Skip to content

Issue with background image vertical alignment in single-row reel #188

Description

@daveadotdev

The situation is this:

  • I have a single-row looping reel. I have set spacing:2 which means that even though the reel area is 100px wide, for each frame the background image gets shifted horizontally by 102px. Makes sense, no issues with that.
    • However, at some point in the code, opt.rows gets set to 1, even though I specified rows:0 in the reel setup call.
    • Because rows now equals 1, when the backgroundPosition is calculated, it triggers the logic that handles multi-row situations (but only when spinning 'backwards').
    • This causes the background image to be shifted up one row. Normally this wouldn't be noticed because it's a repeating background, however because I've set spacing=2, it means that the background shifts up 2 pixels whenever spinning in one direction, but not the other!

The calculation in question is (line 1358):

major= major + (rows > 1 ? 0 : (get(_backwards_) ? 0 : get(_rows_)))

...which in the case of a horizontal scroller defines the vertical background position offset.

The implication of the above is that if rows=1, and you're scrolling not-backwards, then the vertical offset factor should be 1 time the height of the image. Spacing gets added to this, hence my original problem. If you're scrolling backwards, then the vertical offset is zero. (OR, if rows was maintained at the value of 0, the vertical offset would be zero, hence my prior fix above)

Here's a fix which works for my specific situation:

major= major + (rows > 1 ? 0 : (get(_backwards_) ? 0 : get(_rows_) - 1)),

But I don't really understand the reasons for the calculations in that line, so the above might screw up other situations...

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions