Skip to content

Fix missing APIs in web engine #3261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions extensions/ccui/uiwidgets/scroll-widget/UIPageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{

/**
* Allocates and initializes a UIPageView.
* Constructor of ccui.PageView. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
* Constructor of ccui.PageView. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
* @example
* // example
* var uiPageView = new ccui.PageView();
Expand Down Expand Up @@ -112,10 +112,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{
return;

var pageCount = this._getPageCount();
forceCreate = forceCreate || true;
if (pageIdx < 0 || pageIdx >= pageCount) {
if (forceCreate) {
if (pageIdx > pageCount)
if (pageIdx > pageCount) {
cc.log("pageIdx is %d, it will be added as page id [%d]", pageIdx, pageCount);
}
var newPage = this._createPage();
newPage.addChild(widget);
this.addPage(newPage);
Expand Down Expand Up @@ -216,6 +218,33 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{
return this._pages.length;
},

getCurrentPageIndex: function() {
return this._curPageIdx;
},

setCurrentPageIndex: function(index) {
if (index < 0 || index >= this._getPageCount())
{
return;
}
this._curPageIdx = index;
this._doLayoutDirty = true;
},

/**
* @deprecated use setCurrentPageIndex instead.
*/
setCurPageIndex: function(index) {
this.setCurrentPageIndex(index);
},

/**
* @deprecated use getCurrentPageIndex instead.
*/
getCurPageIndex: function() {
return this.getCurrentPageIndex();
},

/**
* Get x position by index
* @param {number} idx
Expand Down