Exemplo n.º 1
0
        public void OnScroll(ObservableWebView view, int x, int y)
        {
            bool autoScroll = PreferenceManager.GetDefaultSharedPreferences(Activity.ApplicationContext).GetBoolean("autoScroll", true);

            if (!autoScroll)
            {
                return;
            }

            float viewHeight      = view.Height;
            float primaryHeight   = primaryWebview.ContentHeight * primaryWebview.Scale;
            float secondaryHeight = secondaryWebview.ContentHeight * secondaryWebview.Scale;

            // Scroll primary
            if (view == primaryWebview)
            {
                float primaryYPos = Java.Lang.Math.Round(view.ScrollY * (secondaryHeight - viewHeight) / (primaryHeight - viewHeight));
                secondaryWebview.ScrollTo(x, (int)primaryYPos);
            }

            // Scroll secondary
            if (view == secondaryWebview)
            {
                float secondaryYPos = Java.Lang.Math.Round(view.ScrollY * (primaryHeight - viewHeight) / (secondaryHeight - viewHeight));
                primaryWebview.ScrollTo(x, (int)secondaryYPos);
            }
        }