-
Notifications
You must be signed in to change notification settings - Fork 273
fix(ui5-carousel): enhance public api #3360
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
Conversation
packages/main/src/Carousel.js
Outdated
@@ -95,28 +95,16 @@ const metadata = { | |||
}, | |||
|
|||
/** | |||
* Defines the index of the initially selected item. | |||
* Defines the page of the initially selected item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defines the initially selected page
* @type {Integer} | ||
* @defaultvalue 0 | ||
* @public | ||
*/ | ||
selectedIndex: { | ||
selectedPage: { | ||
type: Integer, | ||
defaultValue: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to change the defaultValue to 1 and use indexes, starting from 1 rather than 0.
The current behaviour is a little strange. If I want to show the 5th page, I have to say carousel.selectedPage = 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this property is private let's call it "_selectedIndex". Also I prefer 0-based indexing to be conistent with HTMLCollection, but we can discuss this
The infiniteScrollOffset property and load-more event and visibleItemsIndices was added to the navigate event, selectedIndex was renamed ti selectedPage
The infiniteScrollOffset property and load-more event were removed, visibleItemsIndices was added to the navigate event, selectedIndex was renamed to selectedPage carousel-api-enhancments
8fbffe9
to
e97bbee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigateTo
method should be implemented as well
visibleItemsIndexes
public readonly getter returning an array
packages/main/src/Carousel.js
Outdated
*/ | ||
infiniteScrollOffset: { | ||
selectedPage: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add since tag
packages/main/src/Carousel.js
Outdated
@@ -181,29 +169,22 @@ const metadata = { | |||
events: /** @lends sap.ui.webcomponents.main.Carousel.prototype */ { | |||
|
|||
/** | |||
* Fired whenever the <code>selectedIndex</code> changes due to user interaction, | |||
* Fired whenever the <code>selectedPage</code> changes due to user interaction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fired whenever the selectedPage
property changes ...
packages/main/src/Carousel.js
Outdated
*/ | ||
infiniteScrollOffset: { | ||
selectedPage: { | ||
type: Integer, | ||
defaultValue: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesterday we agreed that the selectedPage should start from 0
packages/main/src/Carousel.js
Outdated
|
||
if (this.selectedIndex - 1 < 0) { | ||
if (this.selectedPage - 1 < 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
packages/main/src/Carousel.js
Outdated
|
||
/** | ||
* Defines when the <code>load-more</code> event is fired. If not applied the event will not be fired. | ||
* Defines the initially selected page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedIndex
should remain as private property. This should be added as BREAKING_CHANGE in the description of the PR
packages/main/src/Carousel.js
Outdated
* when the user clicks on the navigation arrows or while resizing, | ||
* based on the <code>items-per-page-l</code>, <code>items-per-page-m</code> and <code>items-per-page-s</code> properties. | ||
* | ||
* @event | ||
* @param {Integer} selectedIndex the current <code>selectedIndex</code>. | ||
* @param {Integer} selectedPage the current <code>selectedPage</code>. | ||
* @param {Array} visibleItemsIndexes the indices of the visible items <code>selectedPage</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a readonly getter, rather than an event parameter
BREAKING_CHANGE Added "visibleItemsIndices" public getter returning an array Added "navigateTo" method that navigates to an item Made "selectedIndex" private
* @type {Integer} | ||
* @defaultvalue 0 | ||
* @public | ||
*/ | ||
selectedIndex: { | ||
selectedPage: { | ||
type: Integer, | ||
defaultValue: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this property is private let's call it "_selectedIndex". Also I prefer 0-based indexing to be conistent with HTMLCollection, but we can discuss this
Removed the uses of the selectedIndex attribute from the outside. One test is no longer relevant. |
Part of #3107
New features:
Added "visibleItemsIndices" public getter returning an array
Added "navigateTo" method that navigates to an item
BREAKING_CHANGE:
selectedIndex
property is deprecatedinfiniteScrollOffset
property is deprecatedload-more
event is deprecated