Created
February 23, 2012 17:33
-
-
Save ryanjduffy/1893942 to your computer and use it in GitHub Desktop.
Enyo wrapper for cubiq's iScroll 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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