diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo/dojox/layout/ext-dijit | |
Diffstat (limited to 'js/dojo/dojox/layout/ext-dijit')
| -rw-r--r-- | js/dojo/dojox/layout/ext-dijit/layout/StackContainer-touch.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/js/dojo/dojox/layout/ext-dijit/layout/StackContainer-touch.js b/js/dojo/dojox/layout/ext-dijit/layout/StackContainer-touch.js new file mode 100644 index 0000000..48b795e --- /dev/null +++ b/js/dojo/dojox/layout/ext-dijit/layout/StackContainer-touch.js @@ -0,0 +1,49 @@ +//>>built +// wrapped by build app +define("dojox/layout/ext-dijit/layout/StackContainer-touch", ["dijit","dojo","dojox","dojo/require!dijit/layout/StackContainer"], function(dijit,dojo,dojox){ +dojo.provide("dojox.layout.ext-dijit.layout.StackContainer-touch"); +dojo.experimental("dojox.layout.ext-dijit.layout.StackContainer-touch"); +dojo.require("dijit.layout.StackContainer"); + +// To support "flick" actions on iPhone, iPod Touch, etc. +// Implemented as a mixin to work with StackContainer (horizontal) and AccordionContainer (vertical) +// TODO: use native CSS animations for fx, provide live tracking of touch and perhaps a 'bounce' effect. + +dojo.connect(dijit.layout.StackContainer.prototype, "postCreate", function(){ + this.axis = (this.baseClass == "dijitAccordionContainer") ? "Y" : "X"; + dojo.forEach( + ["touchstart", "touchmove", "touchend", "touchcancel"], + function(p){ + this.connect(this.domNode, p, function(e){ + switch(e.type){ + case "touchmove": + e.preventDefault(); + if(this.touchPosition){ + var delta = e.touches[0]["page" + this.axis] - this.touchPosition; + if(Math.abs(delta) > 100){ + if(this.axis == "Y"){ delta *= -1;} + delete this.touchPosition; + if(delta > 0){ + !this.selectedChildWidget.isLastChild && this.forward(); + }else{ + !this.selectedChildWidget.isFirstChild && this.back(); + } + } + } + break; + case "touchstart": + if(e.touches.length == 1){ + this.touchPosition = e.touches[0]["page" + this.axis]; + break; + } + // else fallthrough + case "touchend": + case "touchcancel": + delete this.touchPosition; + } + }); + }, + this); +}); + +}); |
