<commit_before>﻿using CodeHub.Helpers;
using System;
using UICompositionAnimations;
using UICompositionAnimations.Enums;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CodeHub.Controls
{
    public sealed partial class IncrementalLoadButtonControl : UserControl
    {
        public IncrementalLoadButtonControl()
        {
            this.InitializeComponent();
            this.SetVisualOpacity(0);
            IsHitTestVisible = false;
        }

        public void Dispose()
        {
            if (_RelatedScrollViewer != null)
            {
                _RelatedScrollViewer.ViewChanged -= RelatedScrollViewer_ViewChanged;
                _RelatedScrollViewer = null;
            }
        }

        // The ScrollViewer in use
        private ScrollViewer _RelatedScrollViewer;

        /// <summary>
        /// Gets or sets the minimum vertical offset before the control is shown
        /// </summary>
        public double VerticalOffsetThreshold { get; set; } = 400;

        private bool _ButtonShown;

        /// <summary>
        /// Binds the IncrementalLoadButton to the ScrollViewer contained inside a given DependencyObject
        /// </summary>
        /// <param name="parentObject">The object that contains the ScrollViewer</param>
        public void InitializeScrollViewer(DependencyObject parentObject)
        {
            if (this.Visibility == Visibility.Collapsed) return;
            ScrollViewer scroller = parentObject.FindChild<ScrollViewer>();
            if (scroller == null)
            {
                throw new ArgumentException("The DependencyObject doesn't contain a ScrollViewer");
            }
            if (_RelatedScrollViewer != null)
            {
                _RelatedScrollViewer.ViewChanged -= RelatedScrollViewer_ViewChanged;
            }
            _RelatedScrollViewer = scroller;
            _RelatedScrollViewer.ViewChanged += RelatedScrollViewer_ViewChanged;
        }

        private void RelatedScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            if (sender.To<ScrollViewer>().VerticalOffset >= VerticalOffsetThreshold &&
                !_ButtonShown)
            {
                _ButtonShown = true;
                this.StartXAMLTransformFadeSlideAnimation(null, 1, TranslationAxis.Y, 20, 0, 200, null, null, EasingFunctionNames.SineEaseOut,
                    () => this.IsHitTestVisible = true);
            }
            else if (sender.To<ScrollViewer>().VerticalOffset < VerticalOffsetThreshold &&
                _ButtonShown)
            {
                _ButtonShown = false;
                this.IsHitTestVisible = false;
                this.StartXAMLTransformFadeSlideAnimation(null, 0, TranslationAxis.Y, 0, 20, 200, null, null, EasingFunctionNames.SineEaseOut);
            }
        }
    }
}
<commit_msg>Changed offset that reveals Load more button<commit_after>﻿using CodeHub.Helpers;
using System;
using UICompositionAnimations;
using UICompositionAnimations.Enums;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CodeHub.Controls
{
    public sealed partial class IncrementalLoadButtonControl : UserControl
    {
        public IncrementalLoadButtonControl()
        {
            this.InitializeComponent();
            this.SetVisualOpacity(0);
            IsHitTestVisible = false;
        }

        public void Dispose()
        {
            if (_RelatedScrollViewer != null)
            {
                _RelatedScrollViewer.ViewChanged -= RelatedScrollViewer_ViewChanged;
                _RelatedScrollViewer = null;
            }
        }

        // The ScrollViewer in use
        private ScrollViewer _RelatedScrollViewer;

        /// <summary>
        /// Gets or sets the minimum vertical offset before the control is shown
        /// </summary>
        public double VerticalOffsetThreshold { get; set; } = 60;

        private bool _ButtonShown;

        /// <summary>
        /// Binds the IncrementalLoadButton to the ScrollViewer contained inside a given DependencyObject
        /// </summary>
        /// <param name="parentObject">The object that contains the ScrollViewer</param>
        public void InitializeScrollViewer(DependencyObject parentObject)
        {
            if (this.Visibility == Visibility.Collapsed) return;
            ScrollViewer scroller = parentObject.FindChild<ScrollViewer>();
            if (scroller == null)
            {
                throw new ArgumentException("The DependencyObject doesn't contain a ScrollViewer");
            }
            if (_RelatedScrollViewer != null)
            {
                _RelatedScrollViewer.ViewChanged -= RelatedScrollViewer_ViewChanged;
            }
            _RelatedScrollViewer = scroller;
            _RelatedScrollViewer.ViewChanged += RelatedScrollViewer_ViewChanged;
        }

        private void RelatedScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            if (sender.To<ScrollViewer>().VerticalOffset >= VerticalOffsetThreshold &&
                !_ButtonShown)
            {
                _ButtonShown = true;
                this.StartXAMLTransformFadeSlideAnimation(null, 1, TranslationAxis.Y, 20, 0, 200, null, null, EasingFunctionNames.SineEaseOut,
                    () => this.IsHitTestVisible = true);
            }
            else if (sender.To<ScrollViewer>().VerticalOffset < VerticalOffsetThreshold &&
                _ButtonShown)
            {
                _ButtonShown = false;
                this.IsHitTestVisible = false;
                this.StartXAMLTransformFadeSlideAnimation(null, 0, TranslationAxis.Y, 0, 20, 200, null, null, EasingFunctionNames.SineEaseOut);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.07729636048526863, 'fraction_numerical': 0.006065857885615251, 'mean_word_length': 2.084446819882416, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7482593', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1414, 'n_words': 322}