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 🙏

© 2026 – Pkg Stats / Ryan Hefner

action-mat-button

v0.0.1

Published

>__used in angular project__

Downloads

12

Readme

ActionMatButtonComponent

used in angular project

  • action-mat-button is a extends of material mat-button
  • define your actions,such as double-click triple-click,press-down, throttle

Install

npm install action-mat-button

Usage

(stackblitz example)


Click to Demo Project


ACTION PROP

action :
     D                  mouse-down
     U                  mouse-up
    (start,end)         duration  start default 0, end default Infinity
     click              D-()-U

condition:
     throttle(min,max)  round-throttle  min default 0, max default Infinity

examples:

    1s-2s-press                 D-(1000,2000)-U
    double-click-between-1s     click-(,1000)-click && throttle(,1100)
                                //&& throttle(,1100) is necessary
                                //because in browser click-time is not predictable
    triple-click                click-()-click-()-click
    triple-click-in-2s          click-(0,1500)-click-(0,1500)-click && throttle(,2000) 

USEAGE SCREENSHOOTS

app.module.ts

import {ActionMatButtonModule} from "action-mat-button";
@NgModule({
  imports: [
    ...
    ActionMatButtonModule.forRoot(),
    ....
  ],
  ....
})
export class AppModule {}    

in your page

/*
action =  "click-(,1000)-click && throttle(,1100)" 
     ----Mandatory: action rule

//choose listen-mode or callback-mode , or both
//listen mode
    (listen) = "your_listener_function($event)"
         ----Madatory-in-listen-mode:
         ---- EventEmitter reciever
         ---- listen mode will send full-info,including error/success 
    id
    -----------Optional:define a id for EventEmitter using
    
    ////callback-mode
    [callback] = "your_callback_function"
         ----Madatory-in-callback-mode:
    [callback_params]= "your_callback_params"  
         ----Optional: callback_function params
     

disable_interval  
    ---------Optional:disbaled-time after each action-round
    ---------default 100ms


*/


<action-mat-button 
    mat-raised-button
    id="double-click during 1 sec"
    action = "click-(,1000)-click && throttle(,1100)"
    (listen) = "listen($event)" 
    [disabled]="disabled"
>
    DOUBLE-CLICK during 1S
</action-mat-button>  

double click

<action-mat-button 
    mat-raised-button
    id="double-click during 1 sec"
    action = "click-(,1000)-click && throttle(,1100)"
    (listen) = "listen($event)" 
    [disabled]="disabled"
>
    DOUBLE-CLICK during 1S
</action-mat-button>    

##ts example for self-defined listner


    public listen = ($event) => {
      simple_throttle(this);
      if ($event.error) {
         error_handler(this,$event);
      } else {
         success_handler(this,$event);
      }
    };


    function success_handler(instance,$event) {
          instance.toastr.success(
            'Well done!',
            'Button: '+$event.id,
            {timeOut: 5000}
          );
    }


    function error_handler(instance,$event) {
          instance.toastr.error(
            JSON.stringify($event.error),
            'Button: '+$event.id,
            {timeOut: 5000}
          );
    }


    function simple_throttle(instance) {
      instance.disabled = true;
      let tmout = setTimeout(() => {
        instance.disabled = false;
        instance.cdr.detectChanges();
        clearTimeout(tmout);
        tmout = null;
      }, instance.disable_interval);
    }        

SUCCESS

triple click

    <action-mat-button
        mat-raised-button
        color="accent"
        id="triple-click during 3 sec"
        action = "click-(,1000)-click-(,1000)-click && throttle(,3000)"
        (listen) = "listen($event)"
        [disabled]="disabled"
    >
        TRIPLE-CLICK during 3s, average 1s
    </action-mat-button>

FAIL

long press

    <action-mat-button 
        mat-flat-button
        color="primary"
        id="press 4s-6s then click"
        action = "D-(4000,6000)-U-()-click && throttle(,8000)"
        (listen) = "listen($event)" 
        [disabled]="disabled"
    >
        PRESS 4S->6S THEN CLICK,finish it in 8S
    </action-mat-button> 

min-throttle

    <action-mat-button
        mat-raised-button
        color="warning"
        id="finish slow double click between 2s-3s"
        action = "click-()-click && throttle(2000,3000)"
        (listen) = "listen($event)"
        [disabled]="disabled"
    >
        SLOW-DOUBLE-CLICK,between 2s-3s
    </action-mat-button>

callback

    <action-mat-button
        mat-raised-button
        id="use callback 4 click in 1.5s"
        action = "click-(,500)-click-(,500)-click-(,500)-click && throttle(,1500)"
        [disable_interval] = "disable_interval"
        [callback] = "callback"
        [callback_params]= "callback_params"
        [disabled]="disabled"
    >
        USE CALLBACK 4 CLICK IN  1.5S
    </action-mat-button>

    //ts
    public callback_params: any = [1, 2, 3,4];
    public callback = (a, b, c,d) => {
      simple_throttle(this);
      alert(a+b+c+d+':NICE JOB')
    };        
  

CALLBACK

advance observe the action progress

    <div fxLayout="row" fxLayoutGap="20px">
        <button mat-mini-fab color="primary" (click)="get_progress()"><mat-icon>menu</mat-icon></button>
        <action-mat-button
            mat-raised-button
            id="get-progress-state"
            action = "D-(1000,)-U-(2000,3000)-click-(2000,3000)-D-(1000,)-U "
            (listen) = "listen($event)"
            [disabled]="disabled"
            #getProgressState
        >
            PROGRESS STATE AND RESET
        </action-mat-button>
        <button mat-mini-fab color="primary" (click)="reset_progress()"><mat-icon>restore_page</mat-icon></button>
    </div>
   
  //ts 
  import { ActionMatButtonComponent } from '../../_components/action-mat-button/action-mat-button.component';

  @ViewChild('getProgressState') btn :ActionMatButtonComponent;

    public get_progress = () =>{
      let ref = this.btn
      alert(JSON.stringify(ref.get_state(),null))
    }
    public reset_progress = () =>{
      let ref = this.btn
      ref.reset();
    }      

PROGRESS

API

ActionMatButtonComponent.listen($event)

$event.id
$event.error 
    - null
    - 
    {
      action: {
        act: 'max_throttle_tmout',
        tmout_at: 1605466254553,
        prev_up_duration: 798,
        error: {
          name: 'Error',
          message: 'total_time_gt_max_throttle',
          total_time: 2002
        }
      },
      throttle: [ 0, 2000 ]
    } 

ActionMatButtonComponent.get_state()

{
  policy: [
    { act: 'down', prev_up_duration_valid_range: [Array] },
    { act: 'up', prev_down_duration_valid_range: [Array] },
    { act: 'down', prev_up_duration_valid_range: [Array] },
    { act: 'up', prev_down_duration_valid_range: [Array] },
    { act: 'down', prev_up_duration_valid_range: [Array] },
    { act: 'up', prev_down_duration_valid_range: [Array] }
  ],
  throttle: [ 0, null ],
  actions: [
    {
      act: 'down',
      prev_up_duration: null,
      down_at: 1605476352648,
      error: null
    },
    {
      act: 'up',
      prev_down_duration: 1874,
      up_at: 1605476354522,
      error: null
    }
  ],
  state: 'up',
  is_browser: true
}

//policy entry
[
   ...
   { act: 'down', prev_up_duration_valid_range: [ 2000, 3000 ] }
   ...
]

ActionMatButtonComponent.reset()

GIT

  • https://github.com/navegador5/nv-angular-action-mat-button.git