Skip to content

Commit

Permalink
feat(content): scrollEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Mar 22, 2018
1 parent 4fcddad commit 5c2678f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ declare global {
export interface IonContentAttributes extends HTMLAttributes {
forceOverscroll?: boolean;
fullscreen?: boolean;
scrollEnabled?: boolean;
scrollEvents?: boolean;
}
}
Expand Down
29 changes: 22 additions & 7 deletions core/src/components/content/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Content {
*/
@Prop() forceOverscroll: boolean;

@Prop() scrollEnabled = true;

@Prop() scrollEvents = false;

Expand All @@ -58,6 +59,9 @@ export class Content {
*/
@Method()
scrollToTop(duration = 300) {
if (!this.scrollEl) {
throw new Error('content is not scrollable');
}
return this.scrollEl.scrollToTop(duration);
}

Expand All @@ -69,16 +73,25 @@ export class Content {
*/
@Method()
scrollToBottom(duration = 300) {
if (!this.scrollEl) {
throw new Error('content is not scrollable');
}
return this.scrollEl.scrollToBottom(duration);
}

@Method()
scrollByPoint(x: number, y: number, duration: number, done?: Function): Promise<any> {
if (!this.scrollEl) {
throw new Error('content is not scrollable');
}
return this.scrollEl.scrollByPoint(x, y, duration, done);
}

@Method()
scrollToPoint(x: number, y: number, duration: number, done?: Function): Promise<any> {
if (!this.scrollEl) {
throw new Error('content is not scrollable');
}
return this.scrollEl.scrollToPoint(x, y, duration, done);
}

Expand Down Expand Up @@ -129,13 +142,15 @@ export class Content {
this.resize();

return [
<ion-scroll
ref={el => this.scrollEl = el as any}
mode={this.mode}
scrollEvents={this.scrollEvents}
forceOverscroll={this.forceOverscroll}>
<slot></slot>
</ion-scroll>,
(this.scrollEnabled)
? <ion-scroll
ref={el => this.scrollEl = el as any}
mode={this.mode}
scrollEvents={this.scrollEvents}
forceOverscroll={this.forceOverscroll}>
<slot></slot>
</ion-scroll>
: <div class='scroll-inner'><slot></slot></div>,
<slot name='fixed'></slot>
];
}
Expand Down
10 changes: 10 additions & 0 deletions core/src/components/content/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ and footers. This effect can easily be seen by setting the toolbar
to transparent.


#### scrollEnabled

boolean


#### scrollEvents

boolean
Expand All @@ -59,6 +64,11 @@ and footers. This effect can easily be seen by setting the toolbar
to transparent.


#### scroll-enabled

boolean


#### scroll-events

boolean
Expand Down

0 comments on commit 5c2678f

Please sign in to comment.