implement pinch to zoom
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
components
|
||||
build
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
|
||||
0.1.7 / 2019-04-21
|
||||
==================
|
||||
* using global-object to get `global.Element` so this code can be safely run inside of non-browser environments (#16, @antialias)
|
||||
|
||||
0.1.6 / 2016-04-01
|
||||
==================
|
||||
|
||||
* index: fall back to `require('component-query')` (#15, @ockham)
|
||||
|
||||
0.1.5 / 2014-07-27
|
||||
==================
|
||||
|
||||
* index: don't throw an Error when given falsey or non-Element nodes
|
||||
|
||||
0.1.4 / 2014-05-27
|
||||
==================
|
||||
|
||||
* force re-publish since something happened with npm
|
||||
|
||||
0.1.3 / 2014-05-27
|
||||
==================
|
||||
|
||||
* package: add "browser" field for browserify
|
||||
|
||||
0.1.2 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: pin "component-query" version
|
||||
* package: add `package.json` file
|
||||
* component: beautify "keywords"
|
||||
|
||||
0.1.1 / 2013-10-15
|
||||
==================
|
||||
|
||||
* use `query.all()` not `query()`
|
||||
* use `proto.matches`
|
||||
|
||||
0.1.0 / 2013-04-15
|
||||
==================
|
||||
|
||||
* use component/query to support fallbacks
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
build: components index.js
|
||||
@component build --dev
|
||||
|
||||
components: component.json
|
||||
@component install --dev
|
||||
|
||||
clean:
|
||||
rm -fr build components template.js
|
||||
|
||||
.PHONY: clean
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
# matches-selector
|
||||
|
||||
Check if an element matches a given selector.
|
||||
|
||||
## Installation
|
||||
|
||||
$ component install component/matches-selector
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var matches = require('matches-selector');
|
||||
matches(el, 'ul li a');
|
||||
// => true
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "matches-selector",
|
||||
"repo": "component/matches-selector",
|
||||
"description": "Check if an element matches a given selector",
|
||||
"version": "0.1.7",
|
||||
"keywords": [
|
||||
"match",
|
||||
"element",
|
||||
"selector"
|
||||
],
|
||||
"dependencies": {
|
||||
"component/query": "*"
|
||||
},
|
||||
"development": {
|
||||
"component/domify": "*"
|
||||
},
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
try {
|
||||
var query = require('query');
|
||||
} catch (err) {
|
||||
var query = require('component-query');
|
||||
}
|
||||
|
||||
/**
|
||||
* Element prototype.
|
||||
*/
|
||||
|
||||
var Element = require('global-object').Element;
|
||||
var proto = Element && Element.prototype || {};
|
||||
|
||||
/**
|
||||
* Vendor function.
|
||||
*/
|
||||
|
||||
var vendor = proto.matches
|
||||
|| proto.webkitMatchesSelector
|
||||
|| proto.mozMatchesSelector
|
||||
|| proto.msMatchesSelector
|
||||
|| proto.oMatchesSelector;
|
||||
|
||||
/**
|
||||
* Expose `match()`.
|
||||
*/
|
||||
|
||||
module.exports = match;
|
||||
|
||||
/**
|
||||
* Match `el` to `selector`.
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} selector
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function match(el, selector) {
|
||||
if (!el || el.nodeType !== 1) return false;
|
||||
if (vendor) return vendor.call(el, selector);
|
||||
var nodes = query.all(selector, el.parentNode);
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
if (nodes[i] == el) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "component-matches-selector",
|
||||
"version": "0.1.7",
|
||||
"description": "Check if an element matches a given selector",
|
||||
"keywords": [
|
||||
"match",
|
||||
"element",
|
||||
"selector"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/component/matches-selector.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"component-query": "*",
|
||||
"global-object": "^1.0.0"
|
||||
},
|
||||
"browser": {
|
||||
"query": "component-query"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Mocha</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="mocha.js"></script>
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<script src="../build/build.js"></script>
|
||||
<script src="tests.js"></script>
|
||||
<script>
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
@charset "UTF-8";
|
||||
body {
|
||||
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
#mocha ul, #mocha li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#mocha ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#mocha h1, #mocha h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mocha h1 {
|
||||
margin-top: 15px;
|
||||
font-size: 1em;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
#mocha h1 a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#mocha h1 a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#mocha .suite .suite h1 {
|
||||
margin-top: 0;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
#mocha h2 {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mocha .suite {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test:hover h2::after {
|
||||
position: relative;
|
||||
top: 0;
|
||||
right: -10px;
|
||||
content: '(view source)';
|
||||
font-size: 12px;
|
||||
font-family: arial;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#mocha .test.pending:hover h2::after {
|
||||
content: '(pending)';
|
||||
font-family: arial;
|
||||
}
|
||||
|
||||
#mocha .test.pass.medium .duration {
|
||||
background: #C09853;
|
||||
}
|
||||
|
||||
#mocha .test.pass.slow .duration {
|
||||
background: #B94A48;
|
||||
}
|
||||
|
||||
#mocha .test.pass::before {
|
||||
content: '✓';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #00d6b2;
|
||||
}
|
||||
|
||||
#mocha .test.pass .duration {
|
||||
font-size: 9px;
|
||||
margin-left: 5px;
|
||||
padding: 2px 5px;
|
||||
color: white;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-ms-border-radius: 5px;
|
||||
-o-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#mocha .test.pass.fast .duration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha .test.pending {
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.pending::before {
|
||||
content: '◦';
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.fail {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test.fail pre {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#mocha .test.fail::before {
|
||||
content: '✖';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre.error {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre {
|
||||
display: inline-block;
|
||||
font: 12px/1.5 monaco, monospace;
|
||||
margin: 5px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-bottom-color: #ddd;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-box-shadow: 0 1px 3px #eee;
|
||||
}
|
||||
|
||||
#report.pass .test.fail {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#report.fail .test.pass {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#error {
|
||||
color: #c00;
|
||||
font-size: 1.5 em;
|
||||
font-weight: 100;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
#stats {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#stats .progress {
|
||||
float: right;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
#stats em {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#stats a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#stats a:hover {
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
#stats li {
|
||||
display: inline-block;
|
||||
margin: 0 5px;
|
||||
list-style: none;
|
||||
padding-top: 11px;
|
||||
}
|
||||
|
||||
code .comment { color: #ddd }
|
||||
code .init { color: #2F6FAD }
|
||||
code .string { color: #5890AD }
|
||||
code .keyword { color: #8A6343 }
|
||||
code .number { color: #2F6FAD }
|
||||
+4699
File diff suppressed because it is too large
Load Diff
+35
@@ -0,0 +1,35 @@
|
||||
|
||||
var matches = require('matches-selector')
|
||||
, domify = require('domify');
|
||||
|
||||
function assert(expr) {
|
||||
if (!expr) throw new Error('assertion failed');
|
||||
}
|
||||
|
||||
var ul = domify('<ul><li><em>foo</em></li></ul>');
|
||||
var li = ul.children[0];
|
||||
var em = li.children[0];
|
||||
|
||||
describe('matchesSelector(el, selector)', function(){
|
||||
it('should work', function(){
|
||||
assert(true === matches(em, 'ul li em'));
|
||||
assert(true === matches(em, 'ul em'));
|
||||
assert(true === matches(em, 'ul > li > em'));
|
||||
assert(false === matches(em, 'ul ul em'));
|
||||
|
||||
assert(true === matches(li, 'ul li'));
|
||||
assert(true === matches(li, 'ul > li'));
|
||||
assert(true === matches(li, 'li'));
|
||||
assert(false === matches(li, 'div > li'));
|
||||
|
||||
assert(true == matches(ul, 'ul'));
|
||||
assert(false == matches(ul, 'div ul'));
|
||||
assert(false == matches(ul, 'body > ul'));
|
||||
})
|
||||
it('should not throw an Error when given `null`', function(){
|
||||
assert(false == matches(null, 'ul'));
|
||||
})
|
||||
it('should not throw an Error when given a TextNode', function(){
|
||||
assert(false == matches(em.firstChild, 'ul'));
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user