Skip to content

Commit

Permalink
fix(Animations): Fix issue with multiple animators holding the same h…
Browse files Browse the repository at this point in the history
…andle to their JS counterparts
  • Loading branch information
kazo0 committed Feb 2, 2021
1 parent 52878b2 commit ee4efaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ protected RenderingLoopAnimator(T from, T to)
private class Metadata : IJSObjectMetadata
{
public static Metadata Instance {get;} = new Metadata();
private Metadata() { }

private static long _handles = 0L;
private Metadata() { }

/// <inheritdoc />
public long CreateNativeInstance(IntPtr managedHandle)
{
var id = Interlocked.Increment(ref _handles);
var id = RenderingLoopAnimatorMetadataIdProvider.Next();
WebAssemblyRuntime.InvokeJS($"Windows.UI.Xaml.Media.Animation.RenderingLoopFloatAnimator.createInstance(\"{managedHandle}\", \"{id}\")");

return id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace Windows.UI.Xaml.Media.Animation
{
internal static class RenderingLoopAnimatorMetadataIdProvider
{
private static long _next = 0L;

public static long Next() => Interlocked.Increment(ref _next);
}
}

0 comments on commit ee4efaa

Please sign in to comment.