|
@@ -3,6 +3,8 @@ export struct SwipeView {
|
|
private _scroller: Scroller = new Scroller()
|
|
private _scroller: Scroller = new Scroller()
|
|
@State h: Length = 40
|
|
@State h: Length = 40
|
|
@State downX: number = 0
|
|
@State downX: number = 0
|
|
|
|
+ onItemClick?: () => void
|
|
|
|
+ onDelete?: () => void
|
|
|
|
|
|
@Builder
|
|
@Builder
|
|
doNothingBuilder() {
|
|
doNothingBuilder() {
|
|
@@ -15,7 +17,16 @@ export struct SwipeView {
|
|
build() {
|
|
build() {
|
|
Scroll(this._scroller) {
|
|
Scroll(this._scroller) {
|
|
Row() {
|
|
Row() {
|
|
- this.customBuilderParam()
|
|
|
|
|
|
+ Column() {
|
|
|
|
+ this.customBuilderParam()
|
|
|
|
+ }.width('100%').onClick(() => {
|
|
|
|
+ this._scroller.scrollTo({
|
|
|
|
+ xOffset: 0, yOffset: 0,
|
|
|
|
+ animation: { duration: 100, curve: Curve.Linear }
|
|
|
|
+ })
|
|
|
|
+ this.onItemClick && this.onItemClick()
|
|
|
|
+ })
|
|
|
|
+
|
|
Text('删除')
|
|
Text('删除')
|
|
.backgroundColor('red')
|
|
.backgroundColor('red')
|
|
.width(70)
|
|
.width(70)
|
|
@@ -23,6 +34,13 @@ export struct SwipeView {
|
|
.height(this.h)
|
|
.height(this.h)
|
|
.textAlign(TextAlign.Center)
|
|
.textAlign(TextAlign.Center)
|
|
.fontSize(16)
|
|
.fontSize(16)
|
|
|
|
+ .onClick(() => {
|
|
|
|
+ this._scroller.scrollTo({
|
|
|
|
+ xOffset: 0, yOffset: 0,
|
|
|
|
+ animation: { duration: 100, curve: Curve.Linear }
|
|
|
|
+ })
|
|
|
|
+ this.onDelete && this.onDelete()
|
|
|
|
+ })
|
|
// if (this.btnBuilder === this.doNothingBuilder) {
|
|
// if (this.btnBuilder === this.doNothingBuilder) {
|
|
// Text('删除')
|
|
// Text('删除')
|
|
// }
|
|
// }
|
|
@@ -59,8 +77,10 @@ export struct SwipeView {
|
|
toxOffset = 70
|
|
toxOffset = 70
|
|
}
|
|
}
|
|
// 滑动指定位置,设置动画
|
|
// 滑动指定位置,设置动画
|
|
- this._scroller.scrollTo({ xOffset: toxOffset, yOffset: 0,
|
|
|
|
- animation: { duration: 300, curve: Curve.Linear } })
|
|
|
|
|
|
+ this._scroller.scrollTo({
|
|
|
|
+ xOffset: toxOffset, yOffset: 0,
|
|
|
|
+ animation: { duration: 300, curve: Curve.Linear }
|
|
|
|
+ })
|
|
// 重置按下的x轴坐标
|
|
// 重置按下的x轴坐标
|
|
this.downX = 0
|
|
this.downX = 0
|
|
break
|
|
break
|