implement pinch to zoom
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
components
|
||||
build
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
|
||||
0.1.4 / 2014-05-27
|
||||
==================
|
||||
|
||||
* component, package: add "browser" as a keyword
|
||||
* package: remove "repo" field
|
||||
|
||||
0.1.3 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: rename module to "component-event"
|
||||
|
||||
0.1.2 / 2013-12-01
|
||||
==================
|
||||
|
||||
* package: add "repository" field
|
||||
* check if addEventListener method is supported by the browser, just once
|
||||
* test: update to test in IE7+
|
||||
|
||||
0.1.1 / 2013-08-16
|
||||
==================
|
||||
|
||||
* fix: default `capture` to `false`
|
||||
|
||||
0.1.0 / 2012-12-18
|
||||
==================
|
||||
|
||||
* add returning of the callback function
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
build: components index.js
|
||||
@component build
|
||||
|
||||
components: component.json
|
||||
@component install --dev
|
||||
|
||||
clean:
|
||||
rm -fr build components
|
||||
|
||||
.PHONY: clean
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
|
||||
# event
|
||||
|
||||
Element event binding component.
|
||||
|
||||
## Installation
|
||||
|
||||
$ component install component/event
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var events = require('event');
|
||||
var a = document.querySelector('a');
|
||||
|
||||
function onclick(e) {
|
||||
e.preventDefault();
|
||||
console.log(e.target);
|
||||
events.unbind(a, 'click', onclick);
|
||||
}
|
||||
|
||||
events.bind(a, 'click', onclick);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .bind(el, type, callback, [capture])
|
||||
|
||||
Bind to `el`'s event `type` with `callback`,
|
||||
returns the `callback` passed.
|
||||
|
||||
### .unbind(el, type, callback, [capture])
|
||||
|
||||
Unbind `el`'s event `type` `callback`,
|
||||
returns the `callback` passed.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "event",
|
||||
"repo": "component/event",
|
||||
"description": "Event binding component",
|
||||
"version": "0.1.4",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"event",
|
||||
"events"
|
||||
],
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
|
||||
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
|
||||
prefix = bind !== 'addEventListener' ? 'on' : '';
|
||||
|
||||
/**
|
||||
* Bind `el` event `type` to `fn`.
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} type
|
||||
* @param {Function} fn
|
||||
* @param {Boolean} capture
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.bind = function(el, type, fn, capture){
|
||||
el[bind](prefix + type, fn, capture || false);
|
||||
return fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbind `el` event `type`'s callback `fn`.
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} type
|
||||
* @param {Function} fn
|
||||
* @param {Boolean} capture
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.unbind = function(el, type, fn, capture){
|
||||
el[unbind](prefix + type, fn, capture || false);
|
||||
return fn;
|
||||
};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "component-event",
|
||||
"description": "Event binding component",
|
||||
"version": "0.1.4",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"event",
|
||||
"events"
|
||||
],
|
||||
"component": {
|
||||
"scripts": {
|
||||
"event/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/event.git"
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Event</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<a href="/something">link</a>
|
||||
|
||||
<script src="../build/build.js"></script>
|
||||
|
||||
<script>
|
||||
var events = require('event');
|
||||
var a = document.getElementsByTagName('a')[0];
|
||||
|
||||
function onclick(e) {
|
||||
e = e || window.e;
|
||||
|
||||
events.unbind(a, 'click', onclick);
|
||||
|
||||
console.log(e);
|
||||
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
events.bind(a, 'click', onclick);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user