3
$\begingroup$

I'm displaying a long row of images with a horizontal scrollbar that should make the images 'go off the screen' to the left or right, instead of wrapping to display all the images on multiple lines.

images = Table[
   ExampleData[RandomChoice[ExampleData["TestImage"]]], {i, 30}];
Pane[Row[images], Scrollbars -> {True, False}]

I don't know how to force the layout engine to not wrap the elements of the array. Appending SpanFromLeft or other spanning restrictions to each element doesn't work. LineBreakWithin -> False would seem to be the easiest solution, but it doesn't work, and isn't 'fully integrated' into the language and 'subject to change'. Perhaps some setting of LinebreakAdjustments would do it, but it probably fails for the same reason LineBreakWithin does.

How can I tell Row to have an infinite page width and not wrap while formatting so that Pane can just scroll one longer-than-screen width row of images?

$\endgroup$

1 Answer 1

2
$\begingroup$
Pane[Style[Row[images], LineBreakWithin -> False, ImageSizeMultipliers -> {.5, .5}], 
  Scrollbars -> {True, False}]

enter image description here

Pane[Style[Row[images], LineBreakWithin -> False, ImageSizeMultipliers -> {.5, .5}], 
 Scrollbars -> {True, False}, ImageSize -> {700, 200}, ScrollPosition -> {300, 100}]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ So that the Pane doesn't become wider than the screen, but also has an appropriate width limit, ImageSize -> {UpTo[CurrentValue[EvaluationNotebook[], WindowSize][[1]] - 100], UpTo[9999]} is useful $\endgroup$
    – Adam
    Sep 13, 2020 at 20:41
  • 1
    $\begingroup$ Two comments. You can use ImageSize -> Full or ImageSize -> Scaled[1] to default to WindowSize, and you can use BaseStyle->{LineBreakWithin->False} as an option to Pane instead of using LineBreakWithin -> False as an option to Style. $\endgroup$
    – Carl Woll
    Sep 14, 2020 at 5:32
  • $\begingroup$ @CarlWoll Perfect! Thanks $\endgroup$
    – Adam
    Sep 14, 2020 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.