浏览代码

clamp offset when show on screen

/main
fzhangtj 6 年前
当前提交
54cb3fd4
共有 3 个文件被更改,包括 17 次插入7 次删除
  1. 8
      Runtime/rendering/viewport.cs
  2. 9
      Runtime/rendering/viewport_offset.cs
  3. 7
      Runtime/widgets/scroll_position.cs

8
Runtime/rendering/viewport.cs


D.assert(targetOffset != null);
if (duration == TimeSpan.Zero) {
offset.jumpTo(targetOffset.offset);
}
else {
offset.animateTo(targetOffset.offset, duration: duration.Value, curve: curve);
}
offset.moveTo(targetOffset.offset, duration: duration.Value, curve: curve);
return targetOffset.rect;
}
}

9
Runtime/rendering/viewport_offset.cs


public abstract IPromise animateTo(float to, TimeSpan duration, Curve curve);
public virtual IPromise moveTo(float to, TimeSpan? duration, Curve curve = null, bool clamp = true) {
if (duration == null || duration.Value == TimeSpan.Zero) {
this.jumpTo(to);
return Promise.Resolved();
} else {
return this.animateTo(to, duration: duration??TimeSpan.Zero , curve: curve ?? Curves.ease);
}
}
public abstract ScrollDirection userScrollDirection { get; }
public abstract bool allowImplicitScrolling { get; }

7
Runtime/widgets/scroll_position.cs


public readonly ValueNotifier<bool> isScrollingNotifier = new ValueNotifier<bool>(false);
public override IPromise moveTo(float to, TimeSpan? duration, Curve curve = null, bool clamp = true) {
if (clamp)
to = to.clamp(this.minScrollExtent, this.maxScrollExtent);
return base.moveTo(to, duration: duration, curve: curve, clamp: clamp);
}
public override bool allowImplicitScrolling {
get { return this.physics.allowImplicitScrolling; }
}

正在加载...
取消
保存