The simplest yet effective jQuery idle plugin

Overview

jquery.inactivity

The simplest yet effective jQuery idle (inactivity) plugin

Download

Purpose

Listen for mouse, keyboard, touch and other custom events and fire "activity" and "inactivity" idle (inactivity) events

Usage

Add either the jquery.inactivity.js or jquery.inactivity.min.js along with the jQuery library to your HTML document

<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script type="text/javascript" src="jquery.inactivity.min.js"></script>

Then call the plugin on the jQuery element that you want to attach it

// attach to document
$(document).inactivity();

You can set your options when you call the plugin for first time and you can also do this later at runtime in the same way

$(document).inactivity( {
    timeout: 1000, // the timeout until the inactivity event fire [default: 3000]
    mouse: true, // listen for mouse inactivity [default: true]
    keyboard: false, // listen for keyboard inactivity [default: true]
    touch: false, // listen for touch inactivity [default: true]
    customEvents: "customEventName", // listen for custom events [default: ""]
    triggerAll: true, // if set to false only the first "activity" event will be fired [default: false]
});

This is how you handle the "activity" and "inactivity" events

$(document).on("activity", function(){
    // function that fires on activity
});

$(document).on("inactivity", function(){
    // function that fires on inactivity
});

And that is how you unattach the plugin from the jQuery element

// unattach from document
$(document).inactivity("destroy");

Dependencies

jQuery 1.7+, also tested with 2.1.4 and 3.0.0

Browser Support

  • IE9+
  • Firefox
  • Chrome
  • Safari
  • Opera
  • iOS Safari
  • Chrome Mobile
  • IE Mobile
  • Opera Mobile
  • Opera Mini
  • Blackberry Browser

Bugs?

Please do submit a ticket if you notice a bug. Thank you :)

You might also like...

Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Lightning Web Chart.js Component Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers Documentation Getting sta

Dec 9, 2022

A simple yet useful todo list webApp

A simple yet useful todo list webApp

Mar 5, 2022

Yet another eslint blame (might) with better adaptability

yet-another-eslint-blame Yet another eslint blame (might) with better adaptability. The input is eslint's output with json format (You can see it here

Mar 7, 2022

A simple yet feature-rich counter that allows you to count the views of your Github README files and profile page

View Counter Purpose This is a simple yet feature-rich counter that allows you to count the views of your github README files and profile page. Featur

Nov 10, 2022

Yet another basic minter.

Mojito Yet another basic minter. Live demo: https://mojito-app.netlify.app/ Motivation The create-eth-app team recently added useDApp in their v1.8.0,

Apr 26, 2022

An unofficial(yet) implementation of Chakra Ui for SvelteJS

Welcome to chakra-ui-svelte 👋 An implementation of Chakra Ui in Svelte Homepage Demo Install pnpm install chakra-ui-svelte import { Box } from "chakr

Dec 31, 2022

A daily activity tracking application that helps to organize your daily tasks and keep track of tasks that have been completed, or yet to be completed.

A daily activity tracking application that helps to organize your daily tasks and keep track of tasks that have been completed, or yet to be completed.

To-Do-List This is my To-Do List project in the Microverse curriculum. Built With HTML CSS Javascript (Webpack) GitHub Live Demo Live Demo Link Gettin

May 7, 2022

The best desktop console calculator yet!

The best desktop console calculator yet!

TBCalc - Console Calculator The best desktop console calculator yet! 🌐 Try TBCalc Online: https://tbcalc.tcb13.com 💻 TBCalc Windows App: https://tbc

Sep 7, 2022

Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collections

eznft Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collec

Sep 21, 2022
Comments
  • Fix bug where all events are unbound if no custom events provided.

    Fix bug where all events are unbound if no custom events provided.

    Namespace event bindings and triggered events. Add curly braces where missing. Clear event bindings after settings are created, to allow clearing custom events properly (fixes bug where all events are unbound).

    opened by RyanEwen 5
  • Breaks hashchange event if bound to window

    Breaks hashchange event if bound to window

    I just noticed that hashchange events no longer make it to my application if I initialize the plugin on 'window'.

    It seems to be okay when using 'document', though.

    opened by RyanEwen 4
  • first time loading a site

    first time loading a site "inactivity" is not fired

    when the site is fresh loaded and keeping the mouse away from the content, the inactivity dont work. its the same, when the browsers refresh button is clicked.(Vivaldi) when pressing F5 or moving the mose one time over the content it starts working.

    opened by intellekta 0
  • Listen load event

    Listen load event

    Currently, we can detect if there is no mouse, touch or keyboard activity; but... is there a way to trigger inactivity if there has been no activity (after loading the page)?

    opened by agmialdea 0
Releases(1.3)
Owner
Alexandros
Alexandros
It shows an effective way to correct bus arrival information using data analytics based on Amazon Serverless such as Kiness Data Stream, Kinesis Data Firehose, S3, and Lambda.

Amazon Serverless를 이용한 실시간 버스 정보 수집 및 저장 본 github repository는 버스 정보를 주기적으로 수집하여 분석할 수 있도록, Amazon Serverless인 Amazon Kinesis Data Stream, Kinesis Data

John Park 4 Nov 13, 2022
zieeco 12 Jul 8, 2022
The simplest way to use AWS/GCP/Azure. From code to cloud in a few minutes.

Utopiops Utopiops is the best way for teams of any size to use cloud (AWS/Azure/GCP), with or without prior experience. We provide a platform that hel

utopiops 98 Dec 25, 2022
This is the simplest possible nodejs api using express.

NodeJS JWT Authentication sample A Todo Application with NodeJS and ExpressJS that uses JWT authentication to manage each user's todos. Available APIs

Yacine Maouche 3 Sep 11, 2022
The simplest implementation of Golang channels, selects and wait groups

TypeScript Channels The simplest implementation of Golang channels, selects and wait groups Installation You can use one of the following package mana

Dimitar Ruskov 9 Dec 8, 2022
This repo has demos, content and documentation of javascript concepts and syntax, in their simplest form. Contribute by sharing your understanding of javascript! Hacktoberfest Accepted!

javascript-documentation open-source hacktoberfest2022 Submit your PR to this javascript-documentation repo ?? ?? ❗ This repo has some of my javascrip

Austin Lynch 7 Nov 2, 2022
Simplest ever I18N 1 KB library for HTML/JavaScript apps.

Ultimate I18n JS ?? Ultimate internationalization library for web applications. Super simple & easy. Less than 1KB (minified and gziped). 0 dependenci

Bart Tadych 8 Dec 22, 2022
A Simple yet extendable jQuery modal script built for use with inline HTML, images, videos, and galleries.

jQuery Chaos Modal A Simple yet extendable jQuery modal script built for use with inline HTML, forms, and images in mind. There are many other modal p

Matthew Sigley 3 Oct 8, 2020
JQuery charCounter - jQuery Character Counter Plugin

jQuery Character Counter A jQuery based character counter for <input> and <textarea> HTML tags. What is this? This simple plugin allows you to add a c

mmmm_lemon 1 Aug 10, 2022
jQuery quick notification plugin. jQuery плагин быстрых уведомлений

Note: English translation by Google Translate Notific About Description: this is a jQuery plugin that helps you display notifications on your site. Li

Webarion 2 Nov 7, 2021