implement pinch to zoom
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# Packages #
|
||||
############
|
||||
# it's better to unpack these files and commit the raw source
|
||||
# git has its own built in compression methods
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
|
||||
# Node.js #
|
||||
###########
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
||||
# Components #
|
||||
##############
|
||||
|
||||
/build
|
||||
/components
|
||||
/vendors
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
|
||||
1.0.1 / 2016-04-01
|
||||
==================
|
||||
|
||||
* component, package: bump matches-selector dependency to 0.1.6 (#4, @ockham)
|
||||
* index: fall back to `require('component-matches-selector')` (#3, @ockham)
|
||||
|
||||
1.0.0 / 2015-07-15
|
||||
==================
|
||||
|
||||
* BREAKING: rewrite to always check self. If you need the old functionality, do closest(el.parentNode, ...)
|
||||
|
||||
0.1.4 / 2014-07-27
|
||||
==================
|
||||
|
||||
* test: add TextNode closest() test case
|
||||
* component, package: pin "matches-selector" to v0.1.5
|
||||
* component, package: fix "repository" URL
|
||||
* package: rename to "component-closest" for npm
|
||||
* index: fix whitespace
|
||||
|
||||
0.1.3 / 2014-05-27
|
||||
==================
|
||||
|
||||
* package: add "browser" section for browserify
|
||||
* package: add "author" field
|
||||
* package: add "repository" field
|
||||
* add `package.json` file
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
build:
|
||||
component install
|
||||
component build
|
||||
|
||||
.PHONY: build
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
# Closest
|
||||
|
||||
Similar to jQuery's `$.fn.closest` and `$.fn.parents`.
|
||||
Finds the closest parent that matches a selector.
|
||||
|
||||
## API
|
||||
|
||||
### closest(element, selector, scope)
|
||||
|
||||
* `element` - will check this elements parents
|
||||
* `selector` - CSS selector to match parents
|
||||
* `scope` - check this element and within. By default, `document.documentElement`.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
closest(document.body, 'html') === document.documentElement
|
||||
closest(document.body, 'body') === document.body
|
||||
closest(document.documentElement, 'body') == null
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "closest",
|
||||
"description": "Find the closest ancestor matching a selector string",
|
||||
"version": "1.0.1",
|
||||
"repo": "component/closest",
|
||||
"dependencies": {
|
||||
"component/matches-selector": "0.1.6"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": [
|
||||
"index.js"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Module Dependencies
|
||||
*/
|
||||
|
||||
try {
|
||||
var matches = require('matches-selector')
|
||||
} catch (err) {
|
||||
var matches = require('component-matches-selector')
|
||||
}
|
||||
|
||||
/**
|
||||
* Export `closest`
|
||||
*/
|
||||
|
||||
module.exports = closest
|
||||
|
||||
/**
|
||||
* Closest
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} selector
|
||||
* @param {Element} scope (optional)
|
||||
*/
|
||||
|
||||
function closest (el, selector, scope) {
|
||||
scope = scope || document.documentElement;
|
||||
|
||||
// walk up the dom
|
||||
while (el && el !== scope) {
|
||||
if (matches(el, selector)) return el;
|
||||
el = el.parentNode;
|
||||
}
|
||||
|
||||
// check scope for match
|
||||
return matches(el, selector) ? el : null;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "component-closest",
|
||||
"description": "Find the closest ancestor matching a selector string",
|
||||
"version": "1.0.1",
|
||||
"author": "Jonathan Ong",
|
||||
"dependencies": {
|
||||
"component-matches-selector": "~0.1.6"
|
||||
},
|
||||
"browser": {
|
||||
"matches-selector": "component-matches-selector"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"closest/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/component/closest.git"
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>closest</title>
|
||||
<script src="../build/build.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="d1">
|
||||
<div id="d2">
|
||||
<div id="d3">hello</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var closest = require('closest')
|
||||
var d1 = document.querySelector('#d1')
|
||||
var d2 = document.querySelector('#d2')
|
||||
var d3 = document.querySelector('#d3')
|
||||
var d4 = document.querySelector('#d3').cloneNode(true);
|
||||
var text = d3.firstChild;
|
||||
var errors = false;
|
||||
|
||||
assert(closest(d3, '#d2'), d2)
|
||||
assert(closest(d3, '#d3'), d3)
|
||||
assert(closest(d3, '#d3'), d3)
|
||||
assert(closest(d3, '#d1'), d1)
|
||||
assert(closest(d3, '#d1', d2), null)
|
||||
assert(closest(d3, '#d1', d1), d1)
|
||||
assert(closest(d4, 'body'), null)
|
||||
assert(closest(document.documentElement, '*'), document.documentElement);
|
||||
assert(closest(text, '#d1'), d1);
|
||||
|
||||
if (!errors) {
|
||||
console.log('all good!');
|
||||
}
|
||||
|
||||
function assert(el1, el2) {
|
||||
if (el1 !== el2) {
|
||||
errors = true;
|
||||
console.log(new Error().stack)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user