js: add slidePosition
This commit is contained in:
parent
f1177e27b4
commit
930593fe0c
@ -1,7 +1,3 @@
|
||||
export default [
|
||||
'src/Counter',
|
||||
'src/Snake',
|
||||
'src/ComplicatedAnimations',
|
||||
'src/.*Demo',
|
||||
'src/Gobang',
|
||||
'src/SliderInListDemo',
|
||||
]
|
67
doric-demo/src/SliderInListDemo.tsx
Normal file
67
doric-demo/src/SliderInListDemo.tsx
Normal file
@ -0,0 +1,67 @@
|
||||
import {
|
||||
Group,
|
||||
List,
|
||||
Panel,
|
||||
layoutConfig,
|
||||
jsx,
|
||||
ListItem,
|
||||
Slider,
|
||||
SlideItem,
|
||||
Image,
|
||||
Color,
|
||||
} from "doric";
|
||||
const imageUrls = [
|
||||
"http://b.hiphotos.baidu.com/image/pic/item/908fa0ec08fa513db777cf78376d55fbb3fbd9b3.jpg",
|
||||
"http://f.hiphotos.baidu.com/image/pic/item/0e2442a7d933c8956c0e8eeadb1373f08202002a.jpg",
|
||||
"http://f.hiphotos.baidu.com/image/pic/item/b151f8198618367aa7f3cc7424738bd4b31ce525.jpg",
|
||||
"http://b.hiphotos.baidu.com/image/pic/item/0eb30f2442a7d9337119f7dba74bd11372f001e0.jpg",
|
||||
"http://a.hiphotos.baidu.com/image/h%3D300/sign=b38f3fc35b0fd9f9bf175369152cd42b/9a504fc2d5628535bdaac29e9aef76c6a6ef63c2.jpg",
|
||||
"http://h.hiphotos.baidu.com/image/pic/item/810a19d8bc3eb1354c94a704ac1ea8d3fd1f4439.jpg",
|
||||
"http://hbimg.b0.upaiyun.com/ca29ea125b7f2d580f573e48eb594b1ef509757f34a08-m0hK45_fw658",
|
||||
"http://b.hiphotos.baidu.com/image/pic/item/908fa0ec08fa513db777cf78376d55fbb3fbd9b3.jpg",
|
||||
"http://f.hiphotos.baidu.com/image/pic/item/0e2442a7d933c8956c0e8eeadb1373f08202002a.jpg",
|
||||
"http://f.hiphotos.baidu.com/image/pic/item/b151f8198618367aa7f3cc7424738bd4b31ce525.jpg",
|
||||
"http://b.hiphotos.baidu.com/image/pic/item/0eb30f2442a7d9337119f7dba74bd11372f001e0.jpg",
|
||||
"http://a.hiphotos.baidu.com/image/h%3D300/sign=b38f3fc35b0fd9f9bf175369152cd42b/9a504fc2d5628535bdaac29e9aef76c6a6ef63c2.jpg",
|
||||
"http://h.hiphotos.baidu.com/image/pic/item/810a19d8bc3eb1354c94a704ac1ea8d3fd1f4439.jpg",
|
||||
];
|
||||
|
||||
@Entry
|
||||
export class SliderInListDemo extends Panel {
|
||||
build(root: Group) {
|
||||
<List
|
||||
parent={root}
|
||||
layoutConfig={layoutConfig().most()}
|
||||
itemCount={50}
|
||||
renderItem={() =>
|
||||
(
|
||||
<ListItem layoutConfig={layoutConfig().mostWidth().fitHeight()}>
|
||||
<Slider
|
||||
layoutConfig={layoutConfig().mostWidth().justHeight()}
|
||||
height={50}
|
||||
backgroundColor={Color.RED}
|
||||
itemCount={imageUrls.length}
|
||||
onPageSlided={function (idx) {
|
||||
const sliderView = this as unknown as Slider;
|
||||
sliderView.slidePosition = idx;
|
||||
}}
|
||||
renderPage={(idx) =>
|
||||
(
|
||||
<SlideItem
|
||||
layoutConfig={layoutConfig().mostWidth().fitHeight()}
|
||||
>
|
||||
<Image
|
||||
layoutConfig={layoutConfig().mostWidth().justHeight()}
|
||||
height={100}
|
||||
imageUrl={imageUrls[idx]}
|
||||
/>
|
||||
</SlideItem>
|
||||
) as SlideItem
|
||||
}
|
||||
/>
|
||||
</ListItem>
|
||||
) as ListItem
|
||||
}
|
||||
/>;
|
||||
}
|
||||
}
|
@ -2641,7 +2641,7 @@ var List = /** @class */ (function (_super) {
|
||||
__metadata$b("design:type", Function)
|
||||
], List.prototype, "onScrollEnd", void 0);
|
||||
__decorate$b([
|
||||
Property,
|
||||
InconsistProperty,
|
||||
__metadata$b("design:type", Number)
|
||||
], List.prototype, "scrolledPosition", void 0);
|
||||
__decorate$b([
|
||||
@ -2820,6 +2820,10 @@ var Slider = /** @class */ (function (_super) {
|
||||
Property,
|
||||
__metadata$a("design:type", Object)
|
||||
], Slider.prototype, "slideStyle", void 0);
|
||||
__decorate$a([
|
||||
InconsistProperty,
|
||||
__metadata$a("design:type", Number)
|
||||
], Slider.prototype, "slidePosition", void 0);
|
||||
return Slider;
|
||||
}(Superview));
|
||||
function slider(config) {
|
||||
|
@ -1993,7 +1993,7 @@ __decorate$b([
|
||||
__metadata$b("design:type", Function)
|
||||
], List.prototype, "onScrollEnd", void 0);
|
||||
__decorate$b([
|
||||
Property,
|
||||
InconsistProperty,
|
||||
__metadata$b("design:type", Number)
|
||||
], List.prototype, "scrolledPosition", void 0);
|
||||
__decorate$b([
|
||||
@ -2147,6 +2147,10 @@ __decorate$a([
|
||||
Property,
|
||||
__metadata$a("design:type", Object)
|
||||
], Slider.prototype, "slideStyle", void 0);
|
||||
__decorate$a([
|
||||
InconsistProperty,
|
||||
__metadata$a("design:type", Number)
|
||||
], Slider.prototype, "slidePosition", void 0);
|
||||
function slider(config) {
|
||||
const ret = new Slider;
|
||||
ret.apply(config);
|
||||
|
@ -3533,7 +3533,7 @@ __decorate$b([
|
||||
__metadata$b("design:type", Function)
|
||||
], List.prototype, "onScrollEnd", void 0);
|
||||
__decorate$b([
|
||||
Property,
|
||||
InconsistProperty,
|
||||
__metadata$b("design:type", Number)
|
||||
], List.prototype, "scrolledPosition", void 0);
|
||||
__decorate$b([
|
||||
@ -3687,6 +3687,10 @@ __decorate$a([
|
||||
Property,
|
||||
__metadata$a("design:type", Object)
|
||||
], Slider.prototype, "slideStyle", void 0);
|
||||
__decorate$a([
|
||||
InconsistProperty,
|
||||
__metadata$a("design:type", Number)
|
||||
], Slider.prototype, "slidePosition", void 0);
|
||||
function slider(config) {
|
||||
const ret = new Slider;
|
||||
ret.apply(config);
|
||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -1106,6 +1106,7 @@ declare module "doric" {
|
||||
minScale: number;
|
||||
maxScale: number;
|
||||
};
|
||||
slidePosition?: number;
|
||||
/**
|
||||
* Reload all list items.
|
||||
* @param context
|
||||
|
@ -22,7 +22,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
import { View, Property, Superview } from "../ui/view";
|
||||
import { View, Property, Superview, InconsistProperty } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
import { deepClone } from "./utils";
|
||||
@ -133,7 +133,7 @@ __decorate([
|
||||
__metadata("design:type", Function)
|
||||
], List.prototype, "onScrollEnd", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
InconsistProperty,
|
||||
__metadata("design:type", Number)
|
||||
], List.prototype, "scrolledPosition", void 0);
|
||||
__decorate([
|
||||
|
1
doric-js/lib/src/widget/slider.d.ts
vendored
1
doric-js/lib/src/widget/slider.d.ts
vendored
@ -33,6 +33,7 @@ export declare class Slider extends Superview {
|
||||
minScale: number;
|
||||
maxScale: number;
|
||||
};
|
||||
slidePosition?: number;
|
||||
/**
|
||||
* Reload all list items.
|
||||
* @param context
|
||||
|
@ -22,7 +22,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Superview, View, Property } from "../ui/view";
|
||||
import { Superview, View, Property, InconsistProperty } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
import { deepClone } from "./utils";
|
||||
@ -110,6 +110,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], Slider.prototype, "slideStyle", void 0);
|
||||
__decorate([
|
||||
InconsistProperty,
|
||||
__metadata("design:type", Number)
|
||||
], Slider.prototype, "slidePosition", void 0);
|
||||
export function slider(config) {
|
||||
const ret = new Slider;
|
||||
ret.apply(config);
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { View, Property, Superview, NativeViewModel } from "../ui/view";
|
||||
import { View, Property, Superview, NativeViewModel, InconsistProperty } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
@ -71,7 +71,7 @@ export class List extends Superview {
|
||||
@Property
|
||||
onScrollEnd?: (offset: { x: number, y: number }) => void
|
||||
|
||||
@Property
|
||||
@InconsistProperty
|
||||
scrolledPosition?: number
|
||||
|
||||
@Property
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Superview, View, Property } from "../ui/view";
|
||||
import { Superview, View, Property, InconsistProperty } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
@ -71,6 +71,9 @@ export class Slider extends Superview {
|
||||
@Property
|
||||
slideStyle?: "zoomOut" | { type: "zoomOut", minScale: number, maxScale: number }
|
||||
|
||||
@InconsistProperty
|
||||
slidePosition?: number
|
||||
|
||||
/**
|
||||
* Reload all list items.
|
||||
* @param context
|
||||
|
Reference in New Issue
Block a user