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