mirror of https://github.com/axmolengine/axmol.git
Add scroll view bar js test
This commit is contained in:
parent
fea84b8af3
commit
8ae6d68640
|
@ -477,6 +477,12 @@
|
|||
func: function () {
|
||||
return new UIScrollViewTest_Vertical_Multiple();
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"UIScrollView Scroll Bar Test",
|
||||
func: function () {
|
||||
return new UIScrollViewTest_ScrollBar();
|
||||
}
|
||||
}
|
||||
],
|
||||
"UIPageView": [
|
||||
|
|
|
@ -603,4 +603,48 @@ var UIScrollViewTest_Vertical_Multiple = UIMainLayer.extend({
|
|||
scrollView.addChild(button_scale9);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var UIScrollViewTest_ScrollBar = UIMainLayer.extend({
|
||||
init: function () {
|
||||
if (this._super()) {
|
||||
var widgetSize = this._widget.getContentSize();
|
||||
//init text
|
||||
this._topDisplayLabel.setString("Scroll bar is red, 65% opacity, auto hide time: 5 sec");
|
||||
this._topDisplayLabel.setFontSize(14);
|
||||
this._topDisplayLabel.x = widgetSize.width / 2.0;
|
||||
this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5;
|
||||
|
||||
this._bottomDisplayLabel.setString("");
|
||||
this._bottomDisplayLabel.x = widgetSize.width / 2;
|
||||
this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3;
|
||||
|
||||
var background = this._widget.getChildByName("background_Panel");
|
||||
|
||||
// Create the scrollview
|
||||
var scrollView = new ccui.ScrollView();
|
||||
scrollView.setTouchEnabled(true);
|
||||
scrollView.setBounceEnabled(true);
|
||||
scrollView.setBackGroundColor(cc.color.GREEN);
|
||||
scrollView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID);
|
||||
scrollView.setDirection(ccui.ScrollView.DIR_BOTH);
|
||||
scrollView.setInnerContainerSize(cc.size(480, 320));
|
||||
scrollView.setContentSize(cc.size(100, 100));
|
||||
var scrollViewSize = scrollView.getContentSize();
|
||||
|
||||
scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2;
|
||||
scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2;
|
||||
|
||||
this._mainNode.addChild(scrollView);
|
||||
|
||||
scrollView.setScrollBarAutoHideTime(5);
|
||||
scrollView.setScrollBarColor(cc.color.RED);
|
||||
scrollView.setScrollBarOpacity(255 * 0.65);
|
||||
scrollView.setScrollBarWidth(5);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue