Skip to content

Commit

Permalink
feat(scrollviewer): Implement the SCP.ScrollOwner (avoids anoying log…
Browse files Browse the repository at this point in the history
…s on wasm, android and ios)
  • Loading branch information
dr1rrb committed Jun 1, 2021
1 parent aa570e4 commit ab3ccb6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Windows.UI.Xaml.Controls
#endif
public partial class ScrollContentPresenter
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || false || __NETSTD_REFERENCE__ || false
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public object ScrollOwner
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,7 @@ private static double GetHorizontalScrollWheelDelta(Size size, double delta)
const double ScrollViewerMinHeightToReflowAroundOcclusions = 32.0f;

private readonly IScrollStrategy _strategy;
private ManagedWeakReference _scroller;

public object ScrollOwner
{
get => _scroller.Target;
set
{
if (_scroller is { } oldScroller)
{
WeakReferencePool.ReturnWeakReference(this, oldScroller);
}

_scroller = WeakReferencePool.RentWeakReference(this, value);
}
}

private ScrollViewer Scroller => ScrollOwner as ScrollViewer;

public bool CanHorizontallyScroll { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ namespace Windows.UI.Xaml.Controls
{
public partial class ScrollContentPresenter : ContentPresenter, ILayoutConstraints
{
#region ScrollOwner
private ManagedWeakReference _scroller;

public object ScrollOwner
{
get => _scroller.Target;
set
{
if (_scroller is { } oldScroller)
{
WeakReferencePool.ReturnWeakReference(this, oldScroller);
}

_scroller = WeakReferencePool.RentWeakReference(this, value);
}
}
#endregion

private void InitializeScrollContentPresenter()
{
this.RegisterParentChangedCallback(this, OnParentChanged);
Expand Down

0 comments on commit ab3ccb6

Please sign in to comment.