Created
January 5, 2013 00:54
-
-
Save anonymous/4458914 to your computer and use it in GitHub Desktop.
QooxDoo TabView extension to implement mousewheel reaction
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
qx.Class.define("qx.ui.tabview.TabView", { | |
extend: qx.ui.tabview.TabView, | |
members: { | |
// Select next tab | |
next: function () { | |
var size = this.getSelectables().length; | |
var idx = this.getSelectables().indexOf(this.getSelection()[0]); | |
if (idx < size - 1) { | |
this.setSelection([this.getSelectables()[idx + 1]]); | |
}; | |
}, | |
// Select previous tab | |
previous: function () { | |
var idx = this.getSelectables().indexOf(this.getSelection()[0]); | |
if (idx > 0) { | |
this.setSelection([this.getSelectables()[idx - 1]]); | |
}; | |
}, | |
// Enable mousewheel reaction | |
mousewheelReaction: function () { | |
this.getChildControl("bar").addListener("mousewheel", function (e) { | |
if (e.getWheelDelta() < 0) { | |
this.previous(); | |
} else { | |
this.next(); | |
}; | |
// stop the propagation | |
// prevent any other widget from receiving this event | |
// e.g. place a selectbox widget inside a scroll container widget | |
e.stopPropagation(); | |
e.preventDefault(); | |
}, this); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment