Furniture shop: the Lynx tutorial app
The two apps the official Lynx tutorials build, Product Gallery and Product Detail, as one Angular app. Tap a picture in the gallery to open its product page, swipe through the photos, and drag the page to the right to go back to the gallery.
The pictures, colors and copy are the tutorials'. Set it next to the ReactLynx original to compare the two.
What it shows
- A waterfall
<list>—list-type="waterfall"lays the pictures into two columns, andestimated-main-axis-size-pxtells the list each picture's height before it loads. See<list>. - An element method —
autoScrollscrolls the gallery by itself. The page calls it withinvoke()once the list has rendered. See Call element methods. - A main-thread scroll handler —
[mainThreadBindscroll]moves the glowing scrollbar on every scroll event, with no change detection in between. See Main-thread scripts. - A swiper from touch events —
src/app/product-detail/swiper.tsdrags the photo strip with[mainThreadCatchtouchmove]and snaps it with arequestAnimationFrametween. Mouse events are caught too, so it drags in a desktop browser. Catching them, rather than binding, keeps a drag on the photos from reaching the stack outlet, which would take a drag to the right as a swipe back. - Two routes in a stack — the gallery and the product page are lazy routes, and the product page reads its
:indexthroughwithComponentInputBinding().<lynx-stack-outlet>slides the product page in over the gallery, and the back chevron, Android's back button or a drag to the right slides it away, back to the gallery as you left it. See Slide screens in and out. - Bundled images — the pictures are
imported, so the build hashes and copies them. See<image>. - Safe areas — the nav bar and the Order button pad themselves with
env(safe-area-inset-*), so on a phone they clear the status bar and the home indicator. See Safe area.
Where the tutorials differ
Angular runs on the main thread, where the elements are, so the parts of the ReactLynx tutorials that cross threads fall away:
- The swiper's touch handlers are class properties with the
'main thread'directive. They read the component's fields and write itscurrentsignal directly; there's norunOnBackground()to reach state on another thread. - A tap on a dot calls the same code the handlers use, without
runOnMainThread(). - The snap's easing is a plain function passed as an input, not a
main-thread:prop.
