Browse files

Adding Touch Gestures.

  • Loading branch information...
1 parent 37b7051 commit d154a2c5d6793405b7771201d83c334eef718c5c @joachimhs committed Feb 8, 2012
Showing with 36 additions and 1 deletion.
  1. +35 −0 src/main/webapp/app/main.js
  2. +1 −1 src/main/webapp/index.html
View
35 src/main/webapp/app/main.js
@@ -84,5 +84,40 @@ EME.ThumbnailPhotoView = Em.View.extend({
});
EME.SelectedPhotoView = Em.View.extend({
+ swipeOptions: {
+ direction: Em.OneGestureDirection.Left | Em.OneGestureDirection.Right,
+ cancelPeriod: 100,
+ numberOfRequiredTouches: 2
+ },
+
+ swipeEnd: function(recognizer) {
+ if (recognizer.swipeDirection === Em.OneGestureDirection.Left) {
+ EME.PhotoListController.nextPhoto();
+ } else if (recognizer.swipeDirection === Em.OneGestureDirection.Right) {
+ EME.PhotoListController.prevPhoto();
+ }
+ },
+
+ pinchChange: function(recognizer) {
+ var newScale = recognizer.get('scale');
+ var curScale = this.$().css('scale');
+ this.$("#selectedImage").css('scale', function(index, value) {
+ return newScale * value;
+ });
+ },
+
+ panOptions: {
+ numberOfRequiredTouches: 1
+ },
+
+ panChange: function(recognizer) {
+ var val = recognizer.get('translation');
+
+ this.$("#selectedImage").css({
+ zIndex: 10,
+ x: '%@=%@'.fmt((val.x < 0) ? '-' : '+', Math.abs(val.x)),
+ y: '%@=%@'.fmt((val.y < 0) ? '-' : '+', Math.abs(val.y))
+ });
+ }
});
View
2 src/main/webapp/index.html
@@ -31,7 +31,7 @@
{{#with content}}
<h1>{{imageTitle}}</h1>
{{#view EME.SelectedPhotoView contentBinding="this" classNames="selectedPhotoItem"}}
- <img {{bindAttr src="content.imageUrl"}}/>
+ <img id="selectedImage" {{bindAttr src="content.imageUrl"}}/>
{{/view}}
{{/with}}
</script>

0 comments on commit d154a2c

Please sign in to comment.