feat: slider add bounces for iOS

This commit is contained in:
pengfei.zhou 2021-04-30 14:28:38 +08:00 committed by osborn
parent f8b983b8d2
commit e621db48b9
11 changed files with 52 additions and 1 deletions

View File

@ -73,6 +73,30 @@ class SliderPanel extends Panel {
space: 10, space: 10,
backgroundColor: Color.RED, backgroundColor: Color.RED,
}), }),
hlayout([
text({
text: "Bounces",
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
textSize: 20,
textColor: Color.BLACK,
textAlignment: gravity().center(),
height: 50,
}),
switchView({
state: true,
onSwitch: (state) => {
pager.bounces = state
},
}),
], {
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
gravity: gravity().center(),
space: 10,
backgroundColor: Color.RED,
}),
pager, pager,
]).also(it => { ]).also(it => {
it.layoutConfig = { it.layoutConfig = {

View File

@ -100,6 +100,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
[self.view reloadData]; [self.view reloadData];
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false]; [self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false];
} }
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else { } else {
[super blendView:view forPropName:name propValue:prop]; [super blendView:view forPropName:name propValue:prop];
} }

View File

@ -2261,6 +2261,10 @@ var Slider = /** @class */ (function (_super) {
Property, Property,
__metadata$7("design:type", Boolean) __metadata$7("design:type", Boolean)
], Slider.prototype, "scrollable", void 0); ], Slider.prototype, "scrollable", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
return Slider; return Slider;
}(Superview)); }(Superview));
function slider(config) { function slider(config) {

View File

@ -1731,6 +1731,10 @@ __decorate$7([
Property, Property,
__metadata$7("design:type", Boolean) __metadata$7("design:type", Boolean)
], Slider.prototype, "scrollable", void 0); ], Slider.prototype, "scrollable", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
function slider(config) { function slider(config) {
const ret = new Slider; const ret = new Slider;
for (let key in config) { for (let key in config) {

View File

@ -3252,6 +3252,10 @@ __decorate$7([
Property, Property,
__metadata$7("design:type", Boolean) __metadata$7("design:type", Boolean)
], Slider.prototype, "scrollable", void 0); ], Slider.prototype, "scrollable", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
function slider(config) { function slider(config) {
const ret = new Slider; const ret = new Slider;
for (let key in config) { for (let key in config) {

1
doric-js/index.d.ts vendored
View File

@ -645,6 +645,7 @@ declare module 'doric/lib/src/widget/slider' {
onPageSlided?: (index: number) => void; onPageSlided?: (index: number) => void;
loop?: boolean; loop?: boolean;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>; slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>; getSlidedPage(context: BridgeContext): Promise<number>;
} }

View File

@ -16,6 +16,7 @@ export declare class Slider extends Superview {
onPageSlided?: (index: number) => void; onPageSlided?: (index: number) => void;
loop?: boolean; loop?: boolean;
scrollable?: boolean; scrollable?: boolean;
bounces?: boolean;
private getItem; private getItem;
private renderBunchedItems; private renderBunchedItems;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>; slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;

View File

@ -84,6 +84,10 @@ __decorate([
Property, Property,
__metadata("design:type", Boolean) __metadata("design:type", Boolean)
], Slider.prototype, "scrollable", void 0); ], Slider.prototype, "scrollable", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
export function slider(config) { export function slider(config) {
const ret = new Slider; const ret = new Slider;
for (let key in config) { for (let key in config) {

View File

@ -52,6 +52,9 @@ export class Slider extends Superview {
@Property @Property
scrollable?: boolean scrollable?: boolean
@Property
bounces?: boolean
private getItem(itemIdx: number) { private getItem(itemIdx: number) {
let view = this.renderPage(itemIdx) let view = this.renderPage(itemIdx)
view.superview = this view.superview = this

View File

@ -3306,6 +3306,10 @@ __decorate$7([
Property, Property,
__metadata$7("design:type", Boolean) __metadata$7("design:type", Boolean)
], Slider.prototype, "scrollable", void 0); ], Slider.prototype, "scrollable", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
function slider(config) { function slider(config) {
const ret = new Slider; const ret = new Slider;
for (let key in config) { for (let key in config) {

File diff suppressed because one or more lines are too long