From 361052656c401b91b42ce0f3ef50b81df6758262 Mon Sep 17 00:00:00 2001 From: thatcher Date: Wed, 27 Feb 2013 06:57:06 -0500 Subject: [PATCH 1/4] patch for pinch zoom point. initial two point touch midpoint is used for duration of pinch-zoom operation. references #17 --- src/mousetracker.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 From d2b9257bc46ee187bdca58203c56489ec27c0958 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 27 Feb 2013 09:59:51 -0800 Subject: [PATCH 2/4] Added "grunt publish" command for copying to site-build --- Gruntfile.js | 49 ++++++++++++++++++++++++++++++++++++++++++------- README.md | 8 ++++++++ package.json | 3 ++- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5edad075..5defac72 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,41 @@ 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) { + grunt.file.copy(abspath, "../site-build/" + (subdir || "") + filename); + }); + }); + + // 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..1dc1a3e3 100644 --- a/package.json +++ b/package.json @@ -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" From 6b492f395d04ba5f512abbc195d19da72862e481 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 27 Feb 2013 10:36:19 -0800 Subject: [PATCH 3/4] Fixed a bug with "grunt publish"; was using the wrong paths --- Gruntfile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5defac72..bd21d089 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -135,7 +135,11 @@ module.exports = function(grunt) { // Copies the contents of the build folder into ../site-build. grunt.registerTask("copy:release", function() { grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) { - grunt.file.copy(abspath, "../site-build/" + (subdir || "") + filename); + var dest = "../site-build/" + + (subdir ? subdir + "/" : "") + + filename; + + grunt.file.copy(abspath, dest); }); }); From 6723450a9a2f902c6435462cc644f8a4ce6fcb49 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 27 Feb 2013 12:00:34 -0800 Subject: [PATCH 4/4] Upped version number to 0.9.121 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dc1a3e3..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",