Comments (5)
They have it. But only recent browsers support it. And edge, for example, doesn't. So, it's nice to have some if (supports) { use native } else { use the library }
.
from idle.js.
Thanks for picking that up. Do you have any suggestion on how to attach to an existing event?
from idle.js.
@shawnmclean Hi. Thanks for fast reaction. I think it's possible to do something like:
function proxyMethod(object, propName, method) {
const existingMethod = object[propName];
let finalMethod = method;
if (typeof existingMethod === 'function') {
finalMethod = (...args) => {
existingMethod(...args);
return method(...args)
};
}
object[propName] = finalMethod;
}
window.onclick = () => console.log('attached earier');
proxyMethod(window, 'onclick', () => console.log('click'));
proxyMethod(window, 'onclick', () => console.log('click #2'));
https://jsfiddle.net/d9dvfajb/
from idle.js.
Using the moment, I would like to ask did you thought about https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/idle support?
from idle.js.
Thanks for the code suggestion.
Hey! If they now have an idle feature in the browser's api, why use this one? (I haven't dug deeper into it to see what constitutes an Idle
state.)
from idle.js.
Related Issues (20)
- broken links after renaming project HOT 1
- Page visibility API HOT 5
- Mousewheel should trigger onActive HOT 1
- Reset away timer when use comes back to page via vis api HOT 1
- Add stop feature
- Add tests for start and stop
- Document Supported Browsers HOT 7
- startAwayTimeout does not exist
- Idle.js interprets page navigation in Firefox as being "away" HOT 2
- Still calling the function startAwayTimeout HOT 4
- Bower support HOT 8
- Is there a way to show a countdown on how long it still takes until an "onAway" event fires? HOT 1
- Touch events support
- Document API
- ES6 and NPM packages HOT 1
- Does not work in IE11 with embedded PDF.
- vendor-prefixed `visibilitychange` event listener is called the second time in newer browsers HOT 4
- onfocus = active?
- test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idle.js.