implement pinch to zoom
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.12'
|
||||
before_script:
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
webpack:
|
||||
@webpack-dev-server 'mocha!./test/test.js' --hot --inline
|
||||
|
||||
test:
|
||||
@karma start
|
||||
|
||||
.PHONY: test
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
# prop-detect
|
||||
|
||||
[](http://travis-ci.org/chemzqm/prop-detect)
|
||||
|
||||
Detect animation properties, it's annoying to install each of them.
|
||||
:smiley:
|
||||
|
||||
## Install
|
||||
|
||||
npm i prop-detect -S
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
var detect = require('prop-detect')
|
||||
var transform = detect.transform
|
||||
var transition = detect.transition
|
||||
var touchAction = detect.touchAction
|
||||
var transitionend = detect.transitionend
|
||||
var has3d = detect.has3d // true or false
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
* `transform` style name
|
||||
* `transition` style name
|
||||
* `touchAction` style name
|
||||
* `transitionend` event name
|
||||
* `has3d` true of false
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
var transform = null
|
||||
;(function () {
|
||||
var styles = [
|
||||
'webkitTransform',
|
||||
'MozTransform',
|
||||
'msTransform',
|
||||
'OTransform',
|
||||
'transform'
|
||||
];
|
||||
|
||||
var el = document.createElement('p');
|
||||
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
if (null != el.style[styles[i]]) {
|
||||
transform = styles[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
/**
|
||||
* Transition-end mapping
|
||||
*/
|
||||
var transitionEnd = null
|
||||
;(function () {
|
||||
var map = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd',
|
||||
'MozTransition' : 'transitionend',
|
||||
'OTransition' : 'oTransitionEnd',
|
||||
'msTransition' : 'MSTransitionEnd',
|
||||
'transition' : 'transitionend'
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `transitionend`
|
||||
*/
|
||||
|
||||
var el = document.createElement('p');
|
||||
|
||||
for (var transition in map) {
|
||||
if (null != el.style[transition]) {
|
||||
transitionEnd = map[transition];
|
||||
break;
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
exports.transitionend = transitionEnd
|
||||
|
||||
exports.transition = require('transition-property')
|
||||
|
||||
exports.transform = transform
|
||||
|
||||
exports.touchAction = require('touchaction-property')
|
||||
|
||||
exports.has3d = require('has-translate3d')
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// Karma configuration
|
||||
// npm i karma karma-cli karma-firefox-launcher karma-mocha karma-webpack mocha --save-dev
|
||||
// node_modules/.bin/karma start --single-run
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'test/test.js'
|
||||
],
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'test/test.js': ['webpack']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['progress'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
webpack: {
|
||||
module: {
|
||||
loaders: [
|
||||
{test: /\.html$/, loader: 'html'}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['Firefox'],
|
||||
|
||||
webpackMiddleware: {
|
||||
noInfo: true
|
||||
},
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true
|
||||
});
|
||||
};
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "prop-detect",
|
||||
"version": "1.1.0",
|
||||
"description": "detect the properties in one lib",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/chemzqm/prop-detect.git"
|
||||
},
|
||||
"keywords": [
|
||||
"detect",
|
||||
"property",
|
||||
"animation"
|
||||
],
|
||||
"author": "chemzqm@gmail.com",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chemzqm/prop-detect/issues"
|
||||
},
|
||||
"homepage": "https://github.com/chemzqm/prop-detect#readme",
|
||||
"devDependencies": {
|
||||
"karma": "^0.13.15",
|
||||
"karma-cli": "^0.1.1",
|
||||
"karma-firefox-launcher": "^0.1.6",
|
||||
"karma-mocha": "^0.2.0",
|
||||
"karma-webpack": "^1.7.0",
|
||||
"karma-wrap-preprocessor": "^0.1.0",
|
||||
"mocha": "^2.3.3",
|
||||
"mocha-loader": "^0.7.1",
|
||||
"webpack": "^1.12.3",
|
||||
"webpack-dev-server": "^1.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"has-translate3d": "0.0.3",
|
||||
"touchaction-property": "0.0.1",
|
||||
"transition-property": "^1.0.1"
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*global describe, it*/
|
||||
var assert = require('assert')
|
||||
var detect = require('..')
|
||||
|
||||
describe('prop-detect', function() {
|
||||
it('should be transition', function () {
|
||||
assert(/transition/i.test(detect.transition))
|
||||
})
|
||||
|
||||
it('should be transform', function () {
|
||||
assert(/transform/i.test(detect.transform))
|
||||
})
|
||||
|
||||
it('should be touchAction', function () {
|
||||
if (detect.touchAction) {
|
||||
assert.equal('touchAction', detect.touchAction)
|
||||
} else {
|
||||
assert.equal(null, detect.touchAction)
|
||||
}
|
||||
})
|
||||
|
||||
it('should be transitionend', function () {
|
||||
assert(/transition/i.test(detect.transitionend))
|
||||
})
|
||||
|
||||
it('should be has3d', function () {
|
||||
assert.equal(detect.has3d, true)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user