implement pinch to zoom
This commit is contained in:
+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;
|
||||
}
|
||||
Reference in New Issue
Block a user