Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

AngularJS: LimitTo

(0 reviews)

Parameter order matters in ng-repeat

While building our new timeline app, speed has always been tricky; even if we are trying to show 1k events at once over a span of several years, we hope the app will feel responsive. Accordingly, we’re looping through all available events and reserving a space for them in the DOM whether they are visible or not. This can cause some pretty big slowdowns as our event count grows.

Timeline.

Timeline. Events only rendered as users scroll them into view.

This all happens within an ng-repeat directive that generates an <li> for each event. We already hide the content of the <li> if it’s out of scroll range but to get faster we needed a way to not even render the <li> element itself while a user’s adjusting the range of visible events. limit

To to the rescue. I was able to utilize the limitTo filter and only render enough li’s to fill the screen until the user is done adjusting the range slider. Once they stop adjusting the slider then the limitTo filter changes to show all events. The net effect is when a user is sliding the range slider we limit what we are showing, then when they are done everything shows, speeding up user interaction considerably.

One problem I thought I had was that it wasn’t sorting before we ran the limitTo filter so it would display different results when changing the slider range. That ended up being an easy fix as I just needed to swap the limitTo filter to go last in the ng-repeat directive.

limitTo at the end of ng-repeat

limitTo at the end of ng-repeat

The post AngularJS: LimitTo appeared first on SeedCode.

Source

0 Comments

Recommended Comments

There are no comments to display.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.