GithubHelp home page GithubHelp logo

c7hm4r / attrchange Goto Github PK

View Code? Open in Web Editor NEW

This project forked from meetselva/attrchange

0.0 2.0 0.0 129 KB

onattrchange listener

License: GNU General Public License v3.0

JavaScript 100.00%

attrchange's Introduction

###attrchange

attrchange is a simple jQuery plugin to bind a listener function on attribute change of an element. The handler function is triggered when an attribute is added, removed or modified to the element.

This core attrchange plugin uses one of the following compatible methods based on the browser to detect an attribute change,

  1. Mutation Observer
  2. DOMAttrModified
  3. onpropertychange
Latest Updates:

The plugin code is majorly refactored to support extensions. Extensions are simple independent addons to the core plugin to performs a specific function.

In the last release, The plugin code is refactored to move the extensions code to a new file [attrchange_ext.js] (https://raw.githubusercontent.com/meetselva/attrchange/6e2cd8df1c5e365b6fd0400ae270a1a6955f4785/attrchange.js). The core plugin attrchange.js should still work independently.

Following are some of the useful addon added to the extensions,

  1. Polling: Added Polling to detect attrchange by polling
    • This technique is extensive but useful at times based on the requirement
    • Added 2 modes, 1. Simple polling 2. Computed polling
    • Simple Polling is the basic polling where the callback is triggered when an attribute is modified programmatically
    • Computed Polling is extensive but useful to detect any style property changes
  2. Disconnect: Allows to stop listenting when an attribute is modified
    • 2 modes of disconnect 1. Physical 2. Logical
    • Logical disconnect is a temporary disconnect. We can re-connect to the handler anytime using the reconnect function
    • Physical disconnect is permanent and cannot be reconnected, however you can establish a new connection anytime
  3. Re-connect: Allows to re-connect a connection that was logically disconnected
  4. Remove: is same as Physical disconnect that removes the listener function
  5. Get Properties: Returns an object with information about the connection
    • method Returns a String information about the method that is used to detect an attribute change. It should be one of the values in ['propertychange', 'DOMAttrModified', 'Mutation Observer', 'polling']
    • isPolling Returns a Boolean. True if the selected method is polling, else returns false
    • pollingInterval Returns an integer value of the polling interval.
    • status Returns a String information about the current connection status. It should be one of the values in ['connected', 'disconnected', 'removed']

Important Note: The below documentation link is for the core plugin and the information about extension are not available yet. I am working on a new website for documenation ๐Ÿ˜‰, until then please refer to the samples under examples folder to know about extensions.

Feel free to drop a comment or feedback at http://meetselva.github.io/#disqus or report an issue at https://github.com/meetselva/attrchange/issues

Full Documentation:

http://meetselva.github.com/attrchange/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.