npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-waypoint

v0.0.1

Published

The default blueprint for ember-cli addons.

Downloads

2

Readme

ember-waypoint

I'm very open to feedback on this addon. I made this because I was using intersection observers for a couple of different things and thought it'd be cool to have an easier way to use them. If you have a cool idea or suggestion to make this better, please let me know :)

Execute a function whenever you scroll to an element. Uses the shiny new Intersection Observer API under the hood. Inspired by Waypoints and the excellent React Waypoint.

Ember Waypoint can be used to build things like lazy loading images, infinite scroll, scrollspies, or docking elements to the viewport on scroll.

View the demo.

Installation

ember install ember-waypoint

Ember Waypoint includes this polyfill since the intersection observer is still a WIP in some browsers. Further versions might exclude the polyfill as browser support improves.

Usage

Suppose we need to show a 'scroll to top' button by figuring out if the user has scrolled down to a certain part of the page. An easy way to do this would be,

{{way-point onEnter=(action "showScrollUp") onLeave=(action "hideScrollUp")}}

In this case, you could think of the way-point as a line across the page. To do stuff when certain elements enter the viewport, you can wrap them with the way-point component.

{{#way-point onEnter=(action "toggleVisibility" true)}}
  <div class="media">
    {{#if isVisible}}
      <img src="profile.jpg"/>
    {{else}}
      <img src="placeholder.jpg"/>
    {{/if}}
    <p>{{name}}</p>
  </div>
{{/way-point}}

Callbacks

Ember-Waypoint accepts closure actions for it's callbacks.

  • onEnter - Called when any part of the child is visible in the viewport
  • onLeave - Called when all of the child has exited the viewport.

An element outside the viewport can be on either at the top or at the bottom, so there are always two positions when the onLeave and onEnter callbacks will be called.

All callbacks receive an array of intersection observer entries as it's final argument.

Props

  • rootElement - The element that is used as the viewport for checking visiblity. Defaults to the browser viewport if not specified.
  • threshold - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. Interpolates to the threshold property in the Intersection Observer API.
  • offsets - Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). Interpolates to the rootMargin property in the Intersection Observer API.

License

This project is licensed under the MIT License.