Marquee
v0.0.10
The Mishka Chelekom Mob Marquee shows content in a horizontal rail that you flick with your finger on iOS and Android. It is the native port of the headless Marquee without the continuous animation, and it runs on Mob.
Overview of the Mob Marquee component for iOS and Android
A marquee is defined by an animation: a CSS @keyframes translation that loops forever. Mob exposes no animation primitive to a render function, which means no transform, no keyframes and no per-frame driver. A component cannot run its own timer either, because the timer would fire once per render. Driving the loop from the screen would re-render the whole tree on every frame, which is the wrong trade for decorative motion.
So Marquee renders its static form. The content sits in a horizontal scroller that you flick, with the repeated group the web version uses so that its loop shows no jump. It is the same content and it is readable. It moves under your finger instead of on its own.
The children are the content. Marquee repeats them repeat times, 2 by default, and puts a spacer of space between the repeats, 24 by default. The rail is a horizontal Scroll Area. An id registers that scroller so a screen can move it from a handler, the way the Scroller arrows do with MishkaScroller.nudge/3.
Marquee keeps no state and sends no events. See the Mob documentation for how screens render and handle messages.
Generate the marquee component
Run this from your Mob app's root to add the component to lib/<app>/components/:
mix mishka.ui.gen.mob marqueeThe generator registers the tag, so you can use it in ~MOB markup. Marquee builds on Scroll Area, so the generator also generates scroll_area without asking, because the dependency is a compile-time one. The examples on this page use the mishka_ prefix of the showcase app (--module-prefix mishka_), so the tag is <MishkaMarquee>. Without a prefix, the tag is <Marquee>.
Marquee rail of repeated content
This is the static form. The ticker is repeated three times in a horizontal rail, and you flick it sideways to move it.
Marquee rail of repeated content
<MishkaMarquee repeat={3}>{[ticker()]}</MishkaMarquee>ticker() is a helper in the showcase that returns a row of words and spacers: BEAM, OTP, Elixir, Mob and Chelekom, separated by bullets. Any node works as content. The showcase also sets height={32} on the rail.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
repeat | integer | 2 | How many times the content is repeated. |
space | number | 24 | Gap between the repeats. |
height | number | nil | Rail height. |
id | string | nil | Registers the scroller so a screen can drive it. |
Differences from the web component
- The animation is not ported. The rail scrolls under your finger.
class,track_classandgroup_classare not ported.idregisters the scroller instead of naming a DOM element.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
repeat
|
integer
|
2
| — | No | How many times the content is repeated. |
space
|
number
|
24
| — | No | Gap between repeats. |
height
|
number
| — | — | No | Rail height. |
id
|
string
| — | — | No | Registers the scroller so a screen can drive it. |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
marquee
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.mob marquee