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

@smip/ngx-viewed

v3.1.1

Published

Angular library for fixing the fact of viewing posts, comments, images, etc.

Downloads

9

Readme

NgxViewed

Angular library for fixing the fact of viewing posts, comments, images, etc.

The library uses IntersectionObserver

Demo

Installation

Run npm install @smip/ngx-viewed -S

Add NgxViewedModule import to your module:

import { NgxViewedModule } from '@smip/ngx-viewed';

...

@NgModule({
  imports: [
    ...
    NgxViewedModule
    ...
  ],
  ...
})

Usage

Add ngxViewedWatcher directive to element witch will be observable.

Directive ngxViewedWatcher provide next input parameters:

  • ngxViewedId: any - variable to help you handle outputs. Will be included in every callback.
  • ngxViewedDisabled: boolean - Disable directive.
  • visiblePercent: number - value from 0 to 1. How element should be visible on the screen to start timer. Default: 0.8 (80%)
  • timeToViewed: number - value from 0 in ms. Time when library will emit output event. After this time library finish observe element. Default: 3000
  • ~~auditTime: number - value from 0 in ms. To optimize the work, the library checks the visibility of the element no more than once every x ms. Default: 500~~ [deprecated]
  • tickTime: number - value from 0 in ms. Value must be less of timeToViewed. How often will be emitted ngxViewedTick. Default: 1000;
  • parentScroll: Element - a parent element with scroll (see demo);

Outputs:

  • ngxViewedViewed: { id: any } - will be emitted once for every element after timeToViewed ms. You can use it to fix fact of viewing.
  • ngxViewedTick: { id: any, time: number } - will be emitted every tickTime ms.
  • ngxViewedShown: { id: any } - will be emitted when element is shown.
  • ngxViewedHidden: { id: any, time: number } - will be emitted when element is hidden.

Example

<div
    ngxViewedWatcher
    [ngxViewedId]="'post1'"
    [timeToViewed]="3000"
    [visiblePercent]="0.8"
    (ngxViewedTick)="onTick($event)"
    (ngxViewedShown)="onShown($event)"
    (ngxViewedHidden)="onHidden($event)"
    (ngxViewedViewed)="onViewed($event)"
  >

Deprecated in version 3.0

~~When your observable elements in some block with scroll you should use ngxViewedContainer directive for parent element (with scroll) and ngxViewedContainerWatcher for observable elements.~~

~~ngxViewedContainer directive has next inputs:~~

~~- visiblePercent: number - value from 0 to 1. How container should be visible on the screen to start observe child elements. Default: 0.8 (80%)~~ ~~- auditTime: number - value from 0 in ms. To optimize the work, the library checks the visibility of the container no more than once every x ms. Default: 500~~

~~And outputs:~~

~~- ngxViewedContainerShown: true - will be emitted when container is shown.~~ ~~- ngxViewedContainerHidden: true - will be emitted when container is hidden.~~

~~ngxViewedContainerWatcher directive has same inputs and outputs as ngxViewedWatcher~~

Issues

If you have questions or issues feel free to create new an topic in issues.

License

Licensed under MIT.