diff --git a/Gruntfile.js b/Gruntfile.js index 5edad075..bd21d089 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-contrib-qunit"); grunt.loadNpmTasks("grunt-contrib-connect"); grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-contrib-clean"); var distribution = "build/openseadragon/openseadragon.js", minified = "build/openseadragon/openseadragon.min.js", @@ -43,6 +44,19 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), + clean: { + build: ["build"], + release: { + src: [ + "../site-build/openseadragon", + "../site-build/openseadragon.zip", + "../site-build/openseadragon.tar" + ], + options: { + force: true + } + } + }, concat: { options: { banner: "/**\n * @version <%= pkg.name %> <%= pkg.version %>\n */\n\n" @@ -93,7 +107,7 @@ module.exports = function(grunt) { }, watch: { files: [ "grunt.js", "src/*.js" ], - tasks: "default" + tasks: "build" }, jshint: { options: { @@ -109,20 +123,45 @@ module.exports = function(grunt) { } }); - // Copy task. - grunt.registerTask("copy", function() { + // Copy:build task. + // Copies the image files into the appropriate location in the build folder. + grunt.registerTask("copy:build", function() { grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) { grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename); }); }); - // Default task. - grunt.registerTask("default", ["jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy"]); + // Copy:release task. + // Copies the contents of the build folder into ../site-build. + grunt.registerTask("copy:release", function() { + grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) { + var dest = "../site-build/" + + (subdir ? subdir + "/" : "") + + filename; + + grunt.file.copy(abspath, dest); + }); + }); + + // Build task. + // Cleans out the build folder and builds the code and images into it, checking lint. + grunt.registerTask("build", [ + "clean:build", "jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy:build" + ]); // Test task. - grunt.registerTask("test", ["default", "connect", "qunit"]); + // Builds and runs unit tests. + grunt.registerTask("test", ["build", "connect", "qunit"]); // Package task. - grunt.registerTask("package", ["default", "compress"]); + // Builds and creates the .zip and .tar files. + grunt.registerTask("package", ["build", "compress"]); + // Publish task. + // Cleans the built files out of ../site-build and copies newly built ones over. + grunt.registerTask("publish", ["package", "clean:release", "copy:release"]); + + // Default task. + // Does a normal build. + grunt.registerTask("default", ["build"]); }; diff --git a/README.md b/README.md index e84f2fc9..d37c0cb1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ If you want to build tar and zip files for distribution (they will also appear i grunt package +Note that the `build` folder is masked with .gitignore; it's just for your local use, and won't be checked in to the repository. + +You can also publish the built version to the site-build repository. This assumes you have cloned it next to this repository. The command is: + + grunt publish + +... which will delete the existing openseadragon folder, along with the .zip and .tar files, out of the site-build folder and replace them with newly built ones from the source in this repository; you'll then need to commit the changes to site-build. + ## Testing Our tests are based on [QUnit](http://qunitjs.com/) and [PhantomJS](http://phantomjs.org/); they're both installed when you run `npm install`. At the moment we don't have much in the way of tests, but we're working to fix that. To run on the command line: diff --git a/package.json b/package.json index 2daf64b9..b0daa42d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "OpenSeadragon", - "version": "0.9.120", + "version": "0.9.121", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "dependencies": { "grunt": "~0.4.0", @@ -10,7 +10,8 @@ "grunt-contrib-uglify": "~0.1.1", "grunt-contrib-qunit": "~0.1.1", "grunt-contrib-connect": "~0.1.2", - "grunt-contrib-watch": "~0.2.0" + "grunt-contrib-watch": "~0.2.0", + "grunt-contrib-clean": "~0.4.0" }, "scripts": { "test": "grunt test" diff --git a/src/mousetracker.js b/src/mousetracker.js index 9fd9ffbe..397fd19f 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -695,6 +695,10 @@ THIS[ tracker.hash ].lastPinchDelta = Math.abs( touchA.x - touchB.x ) + Math.abs( touchA.y - touchB.y ); + THIS[ tracker.hash ].pinchMidpoint = new $.Point( + ( touchA.x + touchB.x ) / 2 , + ( touchA.y + touchB.y ) / 2 + ); //$.console.debug("pinch start : "+THIS[ tracker.hash ].lastPinchDelta); } @@ -756,6 +760,7 @@ } if( event.touches.length + event.changedTouches.length == 2 ){ THIS[ tracker.hash ].lastPinchDelta = null; + THIS[ tracker.hash ].pinchMidpoint = null; //$.console.debug("pinch end"); } event.preventDefault(); @@ -961,8 +966,8 @@ onMouseWheelSpin( tracker, { shift: false, - pageX: ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2, - pageY: ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2, + pageX: THIS[ tracker.hash ].pinchMidpoint.x, + pageY: THIS[ tracker.hash ].pinchMidpoint.y, detail:( THIS[ tracker.hash ].lastPinchDelta > pinchDelta ) ? 1 : -1