implement pinch to zoom

This commit is contained in:
marlon-erler
2026-08-30 16:15:14 +02:00
parent ea50704f8a
commit 7eb02f07dc
160 changed files with 15806 additions and 61 deletions
+1
View File
@@ -0,0 +1 @@
node_modules
+28
View File
@@ -0,0 +1,28 @@
0.2.2 / 2014-03-06
==================
* fix require() call again
0.2.1 / 2014-03-01
==================
* make clone work in all environments FOR REAL
* change npm name to component-clone
0.2.0 / 2014-01-27
==================
* make clone work in all environments
0.1.1 / 2014-01-07
==================
* add repo field to component.json
* add tests around cloning functions
* package: fixed package.json
0.1.0 / 2012-10-18
==================
* initial release
+9
View File
@@ -0,0 +1,9 @@
REPORTER = dot
test:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--bail
.PHONY: test
+27
View File
@@ -0,0 +1,27 @@
# clone
Object clone supporting `date`, `regexp`, `array` and `object` types.
## Example
```js
var obj = clone({
a: 'b',
c: [
new Date(),
'tobi',
'jane'
]
})
```
## API
### clone(obj)
Clones `obj` recursively and returns it.
## License
MIT
+15
View File
@@ -0,0 +1,15 @@
{
"name": "clone",
"repo": "component/clone",
"version": "0.2.2",
"dependencies": {
"component/type": "*"
},
"devDependencies": {
"visionmedia/mocha": "*",
"guille/expect.js": "*"
},
"scripts": [
"index.js"
]
}
+57
View File
@@ -0,0 +1,57 @@
/**
* Module dependencies.
*/
var type;
try {
type = require('component-type');
} catch (_) {
type = require('type');
}
/**
* Module exports.
*/
module.exports = clone;
/**
* Clones objects.
*
* @param {Mixed} any object
* @api public
*/
function clone(obj){
switch (type(obj)) {
case 'object':
var copy = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
copy[key] = clone(obj[key]);
}
}
return copy;
case 'array':
var copy = new Array(obj.length);
for (var i = 0, l = obj.length; i < l; i++) {
copy[i] = clone(obj[i]);
}
return copy;
case 'regexp':
// from millermedeiros/amd-utils - MIT
var flags = '';
flags += obj.multiline ? 'm' : '';
flags += obj.global ? 'g' : '';
flags += obj.ignoreCase ? 'i' : '';
return new RegExp(obj.source, flags);
case 'date':
return new Date(obj.getTime());
default: // string, number, boolean, …
return obj;
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "component-clone",
"version": "0.2.2",
"dependencies": {
"component-type": "*"
},
"devDependencies": {
"mocha": "*",
"expect.js": "*"
},
"component": {
"scripts": {
"clone/index.js": "index.js"
}
},
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/component/clone.git"
},
"browser": {
"type": "component-type"
}
}
+80
View File
@@ -0,0 +1,80 @@
/* test dependencies */
var clone = require('..');
var expect = require('expect.js');
/* tests */
describe('clone', function(){
it('date', function(){
var obj = new Date;
var cloned = clone(obj);
expect(cloned.getTime()).to.be(obj.getTime());
expect(cloned).not.to.be(obj);
});
it('regexp', function(){
var obj = /hello/i;
var cloned = clone(obj);
expect(cloned.toString()).to.be(obj.toString());
expect(cloned).not.to.be(obj);
});
it('array', function(){
var obj = [1, 2, 3, '4'];
var cloned = clone(obj);
expect(cloned).to.eql(obj);
expect(cloned).not.to.be(obj);
});
it('object', function(){
var obj = {
a: 1,
b: 2,
c: 3
};
var cloned = clone(obj);
expect(cloned).to.eql(obj);
expect(cloned).not.to.be(obj);
});
it('object combined', function(){
var date = new Date;
var obj = {
a: {
b: [1, 2, date, { hello: 'world' }]
}
};
var cloned = clone(obj);
expect(cloned).to.eql(obj);
expect(cloned.a).not.to.be(obj.a);
expect(cloned.a.b).not.to.be(obj.a.b);
expect(cloned.a.b[2]).not.to.be(obj.a.b[2]);
expect(cloned.a.b[2].getTime()).to.be(obj.a.b[2].getTime());
expect(cloned.a.b[3]).to.eql(obj.a.b[3]);
expect(cloned.a.b[3]).not.to.be(obj.a.b[3]);
});
it('object with functions', function() {
var func = function () { return 'original'; };
var host = { fluent: func };
var cloned = clone(host);
// cloned function matches original
expect(cloned.fluent).to.be(func);
// change cloned function (no longer matches original)
cloned.fluent = function () { return 'updated'; };
expect(cloned.fluent).not.to.be(func);
expect(cloned.fluent()).to.be('updated');
// original function is still in place
expect(func()).to.be('original');
});
});