Skip to content

Commit 0a64ec3

Browse files
author
Erik Rasmussen
committed
added alias for double click, upped to v0.0.4
1 parent 12f1bfb commit 0a64ec3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

NativeListener.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
var React = require('react'),
3-
PropTypes = React.PropTypes,
43
events = [
54
'KeyDown',
65
'KeyPress',
@@ -24,6 +23,12 @@ var React = require('react'),
2423
'MouseOver',
2524
'MouseUp'
2625
],
26+
aliases = {
27+
'DoubleClick': 'dblclick'
28+
},
29+
toEventName = function(event) {
30+
return (aliases[event] || event).toLowerCase();
31+
},
2732
forEach = function (fn) {
2833
var i;
2934
for (i = 0; i < events.length; i++) {
@@ -49,13 +54,13 @@ NativeListener = React.createClass({
4954
bubble = props['on' + event],
5055
stop = props['stop' + event];
5156
if (capture && typeof capture === 'function') {
52-
element.addEventListener(event.toLowerCase(), capture, true);
57+
element.addEventListener(toEventName(event), capture, true);
5358
}
5459
if (bubble && typeof bubble === 'function') {
55-
element.addEventListener(event.toLowerCase(), bubble, false);
60+
element.addEventListener(toEventName(event), bubble, false);
5661
}
5762
if (stop === true) {
58-
element.addEventListener(event.toLowerCase(), function (e) {
63+
element.addEventListener(toEventName(event), function (e) {
5964
e.stopPropagation();
6065
}, false);
6166
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-listener",
33
"description": "A utility component to allow easy access to browser native events",
4-
"version": "0.0.3",
4+
"version": "0.0.4",
55
"homepage": "https://github.com/erikras/react-native-listener",
66
"author": {
77
"name": "Erik Rasmussen",

0 commit comments

Comments
 (0)