Skip to content

Instantly share code, notes, and snippets.

@ryanjduffy
Created February 23, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanjduffy/1893942 to your computer and use it in GitHub Desktop.
Save ryanjduffy/1893942 to your computer and use it in GitHub Desktop.
Enyo wrapper for cubiq's iScroll 4
enyo.kind({
name:"ex.App",
kind:"Control",
components:[
{kind:"cubiq.iScroll", components:[
{kind:"VirtualRepeater", onSetupRow:"setupRow", components:[
{name:"row", onclick:"rowClicked"},
{kind:"Button", onclick:"buttonClicked"},
{kind:"Slider", min:0, max:20}
]},
]}
],
setupRow:function(source, index) {
if(index >=0 && index < 1000) {
this.$.row.setContent("Row " + index);
return true;
}
},
rowClicked:function(source) {
source.applyStyle("font-size", "20pt");
}
});
enyo.kind({
name:"cubiq.iScroll",
kind:"Control",
chrome:[
{name:"client"}
],
rendered:function() {
this.inherited(arguments);
this.scroller = new iScroll(this.$.client.id, {useTransform:false, onScrollMove:enyo.bind(this, "scrollStart"), onScrollEnd:enyo.bind(this, "scrollEnd")});
},
scrollStart:function() {
this._scrolling = true;
},
scrollEnd:function() {
this._scrolling = this._down;
},
captureDomEvent:function(e) {
// when useTransform = false, click fires after scrollEnd so watching mouse state as well
if(e.type === "mousedown") {
this._down = true;
} else if(e.type === "mouseup" && !this._scrolling) {
// release "capture" on mouseup if not scrolling
this._down = false;
} else if(e.type === "click" && (this._down || this._scrolling)) {
this._down = false;
return true;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment