mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
feat(content): scrollEnabled
This commit is contained in:
1
core/src/components.d.ts
vendored
1
core/src/components.d.ts
vendored
@ -801,6 +801,7 @@ declare global {
|
|||||||
export interface IonContentAttributes extends HTMLAttributes {
|
export interface IonContentAttributes extends HTMLAttributes {
|
||||||
forceOverscroll?: boolean;
|
forceOverscroll?: boolean;
|
||||||
fullscreen?: boolean;
|
fullscreen?: boolean;
|
||||||
|
scrollEnabled?: boolean;
|
||||||
scrollEvents?: boolean;
|
scrollEvents?: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export class Content {
|
|||||||
*/
|
*/
|
||||||
@Prop() forceOverscroll: boolean;
|
@Prop() forceOverscroll: boolean;
|
||||||
|
|
||||||
|
@Prop() scrollEnabled = true;
|
||||||
|
|
||||||
@Prop() scrollEvents = false;
|
@Prop() scrollEvents = false;
|
||||||
|
|
||||||
@ -58,6 +59,9 @@ export class Content {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
scrollToTop(duration = 300) {
|
scrollToTop(duration = 300) {
|
||||||
|
if (!this.scrollEl) {
|
||||||
|
throw new Error('content is not scrollable');
|
||||||
|
}
|
||||||
return this.scrollEl.scrollToTop(duration);
|
return this.scrollEl.scrollToTop(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,16 +73,25 @@ export class Content {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
scrollToBottom(duration = 300) {
|
scrollToBottom(duration = 300) {
|
||||||
|
if (!this.scrollEl) {
|
||||||
|
throw new Error('content is not scrollable');
|
||||||
|
}
|
||||||
return this.scrollEl.scrollToBottom(duration);
|
return this.scrollEl.scrollToBottom(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
scrollByPoint(x: number, y: number, duration: number, done?: Function): Promise<any> {
|
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);
|
return this.scrollEl.scrollByPoint(x, y, duration, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
scrollToPoint(x: number, y: number, duration: number, done?: Function): Promise<any> {
|
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);
|
return this.scrollEl.scrollToPoint(x, y, duration, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,13 +142,15 @@ export class Content {
|
|||||||
this.resize();
|
this.resize();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<ion-scroll
|
(this.scrollEnabled)
|
||||||
ref={el => this.scrollEl = el as any}
|
? <ion-scroll
|
||||||
mode={this.mode}
|
ref={el => this.scrollEl = el as any}
|
||||||
scrollEvents={this.scrollEvents}
|
mode={this.mode}
|
||||||
forceOverscroll={this.forceOverscroll}>
|
scrollEvents={this.scrollEvents}
|
||||||
<slot></slot>
|
forceOverscroll={this.forceOverscroll}>
|
||||||
</ion-scroll>,
|
<slot></slot>
|
||||||
|
</ion-scroll>
|
||||||
|
: <div class='scroll-inner'><slot></slot></div>,
|
||||||
<slot name='fixed'></slot>
|
<slot name='fixed'></slot>
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,11 @@ and footers. This effect can easily be seen by setting the toolbar
|
|||||||
to transparent.
|
to transparent.
|
||||||
|
|
||||||
|
|
||||||
|
#### scrollEnabled
|
||||||
|
|
||||||
|
boolean
|
||||||
|
|
||||||
|
|
||||||
#### scrollEvents
|
#### scrollEvents
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
@ -59,6 +64,11 @@ and footers. This effect can easily be seen by setting the toolbar
|
|||||||
to transparent.
|
to transparent.
|
||||||
|
|
||||||
|
|
||||||
|
#### scroll-enabled
|
||||||
|
|
||||||
|
boolean
|
||||||
|
|
||||||
|
|
||||||
#### scroll-events
|
#### scroll-events
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user