feat: add scrollsToTop for scrollable views only for iOS

This commit is contained in:
pengfei.zhou 2023-03-13 19:17:56 +08:00 committed by osborn
parent 0774df96e1
commit 7db5d68db5
30 changed files with 221 additions and 3 deletions

View File

@ -298,6 +298,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"columnSpace" isEqualToString:name]) {
self.columnSpace = [prop floatValue];
[self.view.collectionViewLayout invalidateLayout];

View File

@ -156,6 +156,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"itemCount" isEqualToString:name]) {
self.itemCount = [prop unsignedIntegerValue];
self.needReload = true;

View File

@ -161,6 +161,8 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"itemCount" isEqualToString:name]) {
self.itemCount = [prop unsignedIntegerValue];
self.needReload = true;

View File

@ -50,6 +50,8 @@ - (void)blendView:(UIScrollView *)view forPropName:(NSString *)name propValue:(i
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"onPageSlided" isEqualToString:name]) {
self.onPageSelectedFuncId = prop;
} else {

View File

@ -104,6 +104,8 @@ - (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue
self.view.scrollEnabled = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"content" isEqualToString:name]) {
self.childViewId = prop;
} else if ([@"onScroll" isEqualToString:name]) {

View File

@ -99,6 +99,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
self.propLoop = [prop boolValue];
} else if ([@"bounces" isEqualToString:name]) {
self.view.bounces = [prop boolValue];
} else if ([@"scrollsToTop" isEqualToString:name]) {
self.view.scrollsToTop = [prop boolValue];
} else if ([@"slideStyle" isEqualToString:name]) {
if ([prop isKindOfClass:NSDictionary.class]) {
self.slideStyle = prop[@"type"];

View File

@ -2625,6 +2625,10 @@ var List = /** @class */ (function (_super) {
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "scrollsToTop", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
@ -2780,6 +2784,10 @@ var Slider = /** @class */ (function (_super) {
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "scrollsToTop", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Object)
@ -2888,6 +2896,10 @@ var Scroller = /** @class */ (function (_super) {
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "scrollsToTop", void 0);
return Scroller;
}(Superview));
@ -3315,6 +3327,10 @@ var FlowLayout = /** @class */ (function (_super) {
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "scrollsToTop", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
@ -3574,6 +3590,10 @@ var NestedSlider = /** @class */ (function (_super) {
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "scrollsToTop", void 0);
return NestedSlider;
}(Group));
@ -4065,6 +4085,10 @@ var HorizontalList = /** @class */ (function (_super) {
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

View File

@ -1990,6 +1990,10 @@ __decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "scrollsToTop", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
@ -2120,6 +2124,10 @@ __decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "scrollsToTop", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Object)
@ -2204,6 +2212,10 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "scrollsToTop", void 0);
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -2531,6 +2543,10 @@ __decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "scrollsToTop", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
@ -2748,6 +2764,10 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "scrollsToTop", void 0);
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -3105,6 +3125,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

View File

@ -3530,6 +3530,10 @@ __decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "scrollsToTop", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
@ -3660,6 +3664,10 @@ __decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "scrollsToTop", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Object)
@ -3744,6 +3752,10 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "scrollsToTop", void 0);
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -4071,6 +4083,10 @@ __decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "scrollsToTop", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
@ -4288,6 +4304,10 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "scrollsToTop", void 0);
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -4645,6 +4665,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

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

@ -1030,6 +1030,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from
@ -1089,6 +1093,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
/**
* Set the effect when sliding
* ZoomOut is currently supported
@ -1132,6 +1140,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {
@ -1202,6 +1214,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from
@ -1312,6 +1328,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
addSlideItem(view: View): void;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>;
@ -1475,6 +1495,10 @@ declare module "doric" {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from

View File

@ -37,6 +37,10 @@ export declare class FlowLayout extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from

View File

@ -147,6 +147,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], FlowLayout.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

View File

@ -30,6 +30,10 @@ export declare class HorizontalList extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from

View File

@ -138,6 +138,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

View File

@ -36,6 +36,10 @@ export declare class List extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
canDrag?: boolean;
/**
* @param from

View File

@ -142,6 +142,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], List.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

View File

@ -7,6 +7,10 @@ export declare class NestedSlider extends Group {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
addSlideItem(view: View): void;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>;

View File

@ -46,3 +46,7 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], NestedSlider.prototype, "scrollsToTop", void 0);

View File

@ -20,6 +20,10 @@ export declare class Scroller extends Superview implements JSX.ElementChildrenAt
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
allSubviews(): View[];
toModel(): NativeViewModel;
scrollTo(context: BridgeContext, offset: {

View File

@ -71,3 +71,7 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], Scroller.prototype, "scrollsToTop", void 0);

View File

@ -20,6 +20,10 @@ export declare class Slider extends Superview {
* Take effect only on iOS
*/
bounces?: boolean;
/**
* Take effect only on iOS
*/
scrollsToTop?: boolean;
/**
* Set the effect when sliding
* ZoomOut is currently supported

View File

@ -100,6 +100,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], Slider.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Object)

View File

@ -84,6 +84,12 @@ export class FlowLayout extends Superview {
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
@Property
canDrag?: boolean

View File

@ -81,6 +81,12 @@ export class HorizontalList extends Superview {
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
@Property
canDrag?: boolean
@ -88,8 +94,8 @@ export class HorizontalList extends Superview {
* @param from
* @returns Returns the item of index which can dragged or not.
*/
@Property
itemCanDrag?: (from: number) => boolean
@Property
itemCanDrag?: (from: number) => boolean
/**
* @param from

View File

@ -81,6 +81,12 @@ export class List extends Superview {
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
@Property
canDrag?: boolean

View File

@ -29,6 +29,12 @@ export class NestedSlider extends Group {
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
addSlideItem(view: View) {
this.addChild(view)
}

View File

@ -42,12 +42,19 @@ export class Scroller extends Superview implements JSX.ElementChildrenAttribute
@Property
scrollable?: boolean
/**
* Take effect only on iOS
*/
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
allSubviews() {
return [this.content]
}

View File

@ -56,6 +56,13 @@ export class Slider extends Superview {
*/
@Property
bounces?: boolean
/**
* Take effect only on iOS
*/
@Property
scrollsToTop?: boolean
/**
* Set the effect when sliding
* ZoomOut is currently supported

View File

@ -3605,6 +3605,10 @@ __decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "bounces", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
], List.prototype, "scrollsToTop", void 0);
__decorate$b([
Property,
__metadata$b("design:type", Boolean)
@ -3735,6 +3739,10 @@ __decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "bounces", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Boolean)
], Slider.prototype, "scrollsToTop", void 0);
__decorate$a([
Property,
__metadata$a("design:type", Object)
@ -3819,6 +3827,10 @@ __decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "bounces", void 0);
__decorate$9([
Property,
__metadata$9("design:type", Boolean)
], Scroller.prototype, "scrollsToTop", void 0);
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -4146,6 +4158,10 @@ __decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "bounces", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
], FlowLayout.prototype, "scrollsToTop", void 0);
__decorate$7([
Property,
__metadata$7("design:type", Boolean)
@ -4363,6 +4379,10 @@ __decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "bounces", void 0);
__decorate$5([
Property,
__metadata$5("design:type", Boolean)
], NestedSlider.prototype, "scrollsToTop", void 0);
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -4720,6 +4740,10 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "bounces", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], HorizontalList.prototype, "scrollsToTop", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)

File diff suppressed because one or more lines are too long