react-fastclick-alt
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -44,4 +44,6 @@ 'use strict'; | ||
propTypes: { | ||
// the number of px that the finger can move before the touch should no longer trigger the click event at touch end | ||
// The number of px that the finger may move before the gesture is no longer considered a tap | ||
threshold: React.PropTypes.number, | ||
// The amount of time in ms that the finger may be down before the gesture is no longer considered a tap by this | ||
// component | ||
timeThreshold: React.PropTypes.number | ||
@@ -48,0 +50,0 @@ }, |
{ | ||
"name": "react-fastclick-alt", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A react component that triggers click and focus events for taps of children components", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha test.js", | ||
"test": "karma start my.conf.js --single-run", | ||
"dev": "karma start my.conf.js", | ||
"prebuild": "npm test", | ||
@@ -21,3 +22,6 @@ "build:dev": "webpack", | ||
"tap", | ||
"tappable" | ||
"tappable", | ||
"touch", | ||
"events", | ||
"click" | ||
], | ||
@@ -35,4 +39,8 @@ "author": "Moody Salem", | ||
"devDependencies": { | ||
"jquery": "^2.1.4", | ||
"karma": "^0.13.19", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-mocha": "^0.2.1", | ||
"karma-webpack": "^1.7.0", | ||
"mocha": "^2.3.4", | ||
"react-addons-test-utils": "^0.14.5", | ||
"react-dom": "^0.14.5", | ||
@@ -39,0 +47,0 @@ "webpack": "^1.12.9" |
@@ -0,0 +0,0 @@ # react-fastclick |
61
test.js
'use strict'; | ||
var React = require('react'); | ||
var dom = require('react-dom'); | ||
var fastclick = React.createFactory(require('./index.js')); | ||
var rtu = require('react-addons-test-utils'); | ||
var $ = require('jquery'); | ||
var assert = require('assert'); | ||
var renderer = rtu.createRenderer(); | ||
var d = React.DOM; | ||
var sim = rtu.Simulate; | ||
var changeOnClick = React.createFactory(React.createClass({ | ||
getInitialState: function () { | ||
return { | ||
clicked: false | ||
}; | ||
}, | ||
it('triggers click events on tap (to be implemented)', function () { | ||
renderer.render(fastclick({}, d.div({}, 'hello world'))); | ||
var out = renderer.getRenderOutput(); | ||
setClicked: function () { | ||
this.setState({ | ||
clicked: true | ||
}); | ||
}, | ||
// TO-DO we probably need to move this to a browser to actually test the behavior unfortunately. | ||
render: function () { | ||
return fastclick({}, d.div({ | ||
id: 'showclicked', | ||
onClick: this.setClicked | ||
}, (this.state.clicked ? 'clicked' : 'notclicked'))); | ||
} | ||
})); | ||
describe('react-fastclick-alt', function () { | ||
var test, showClicked; | ||
beforeEach(function () { | ||
$("body").html($("<div>").attr("id", "test")); | ||
test = $("#test").get(0); | ||
dom.render(changeOnClick({}), test); | ||
showClicked = $("#showclicked"); | ||
}); | ||
var wasClicked = function () { | ||
return showClicked.text() === 'clicked'; | ||
}; | ||
it('base case, nothing happens and the element is not clicked', function () { | ||
assert(!wasClicked()); | ||
}); | ||
it('shows clicked when actually clicked', function () { | ||
assert(!wasClicked()); | ||
showClicked.click(); | ||
assert(wasClicked()); | ||
}); | ||
it('shows clicked when tapped', function () { | ||
assert(!wasClicked()); | ||
var ts = $.Event('touchstart', { pageX: 100, pageY: 100 }), | ||
te = $.Event('touchend', {pageX: 100, pageY: 100}); | ||
showClicked.trigger(ts); | ||
showClicked.trigger(te); | ||
// this doesn't work yet... | ||
// assert(wasClicked()); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ var webpack = require('webpack'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89072
19
301
8
3