Skip to content

Commit

Permalink
feat(ui5-carousel): introduce loadMore event (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed May 27, 2020
1 parent 549148d commit e7af480
Show file tree
Hide file tree
Showing 4 changed files with 610 additions and 483 deletions.
29 changes: 29 additions & 0 deletions packages/main/src/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ const metadata = {
defaultValue: 0,
},

/**
* Defines when the <code>loadMore</code> event is thrown. If not applied the event will not be thrown.
* @type {Integer}
* @defaultvalue 1
* @public
* @since 1.0.0-rc.8
*/
infiniteScrollOffset: {
type: Integer,
defaultValue: 1,
},

/**
* Defines the position of arrows.
* <br><br>
Expand Down Expand Up @@ -168,6 +180,17 @@ const metadata = {
selectedIndex: { type: Integer },
},
},

/**
* Fired for the last items of the <code>ui5-carousel</code> if it is scrolled and the direction of scrolling is to the end.
* The number of items for which the event is thrown is controlled by the <code>infiniteScrollOffset</code> property.
* @event
* @public
* @since 1.0.0-rc.8
*/
loadMore: {

},
},
};

Expand Down Expand Up @@ -332,6 +355,8 @@ class Carousel extends UI5Element {
if (this.selectedIndex + 1 > this.pagesCount - 1) {
if (this.cyclic) {
this.selectedIndex = 0;
} else {
return;
}
} else {
++this.selectedIndex;
Expand All @@ -340,6 +365,10 @@ class Carousel extends UI5Element {
if (peviousSelectedIndex !== this.selectedIndex) {
this.fireEvent("navigate", { selectedIndex: this.selectedIndex });
}

if (this.pagesCount - this.selectedIndex <= this.infiniteScrollOffset + 1) {
this.fireEvent("loadMore");
}
}

/**
Expand Down
Loading

0 comments on commit e7af480

Please sign in to comment.