marc-costello / evt Goto Github PK
View Code? Open in Web Editor NEWAn events library for the DOM
License: MIT License
An events library for the DOM
License: MIT License
The ability to raise an event on an element.
For example:
evt('#my-element').on('my-event', function(e) {
console.log(e.message);
});
evt('#my-element').raise('my-event', { message: "hello, world" });
should log "hello, world" to the console
This is probably just an extension of .on()
.
So that we have a way of storing a reference to an element, but without actually referencing the element (because this would be bad).
We can create a unique id of some sort and attach it as an attribute to the DOM element
For example:
evt('#my-element').on('click', function(e) {
...
});
That's it. Not worrying about filtering or event grouping. Just the basics
We need to be able to give name a group of handlers. So that we can turn on or off groups of handlers registered to an element.
For example:
evt('#my-element').on('click.group1', handler);
evt('#my-element').on('click.group2', handler);
evt('#my-element').off('group1');
group2 should still be attached.
It's worth keeping in mind when implementing this that we also plan on being able to call .off('.groupname')
without specifying elements. So the element isn't the root here - the group is.
I can see this having some interesting use cases. I think it's worth putting in.
evt().suspend('.group');
evt().resume('.group');
Performance reasons only...
Remove all event handlers registered on the element.
evt('#my-element').off();
Note: Only remove handlers which have been registered using evt
Having the ability to attach the events to an element higher up the tree, but be triggered by a child.
For example:
evt('table').on('click', 'td', function(e) {
console.log('child td of table clicked');
});
evt('#element1').on('click.multielementgroup' handler);
evt('#element2').on('click.multielementgroup' handler);
evt.suspend('.multielementgroup');
This should suspend all listeners to attached to all elements in the _multielementgroup' group.
So it really doesn't matter about which elements we are applying to. We can choose to interact with groups.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.