tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
833 stars 68 forks source link

Smooth scrolling? #148

Closed Nicks182 closed 8 months ago

Nicks182 commented 10 months ago

Hi

I've been experimenting with using HTML as my GUI for desktop apps. Recently I used the WebView2 control in a WPF app to load an embedded html page in the app's main window and then also include Kestrel web server in the app to host the page so I can access it over the local network.

With WebView2 I was able to set the flag to enable smooth scrolling which makes the UI feel so much nicer and modern. The main issue with this approach is the application size. My app ended up being 213Mb :(

So I'm now currently just messing around/experimenting/figuring things out with Photino, but so far I can't see a way to get smooth scrolling to work... maybe I'm just being an idiot which is quite possible ;)

Setting the scroll-behavior in CSS seems to make no difference.

Is it possible to enable smooth scrolling for my HTML in photino?

philippjbauer commented 8 months ago

We added a way to pass init flags to the browser control in Photino.NET v2.5.0 (just released). You can try to pass --enable-smooth-scrolling as a string via the SetBrowserControlInitParameters method.

public class Program
{
    public static void Main(string[] args)
    {
        string browserControlInitParams = string.Empty;

        if (PhotinoWindow.IsWindowsPlatform)
        {
            // Windows specific initialization parameters
            browserControlInitParams = "--flag --option-with-value=value";
        }
        else if (PhotinoWindow.IsMacOsPlatform)
        {
            // macOS specific initialization parameters
            browserControlInitParams = JsonSerializer.Serialize(new
            {
                flag = true,
                optionWithValue = "value"
            });
        }
        else if (PhotinoWindow.IsLinuxPlatform)
        {
            // Linux specific initialization parameters
            browserControlInitParams = JsonSerializer.Serialize(new
            {
                flag = true,
                optionWithValue = "value"
            });
        }

        PhotinoWindow window = new PhotinoWindow()
            .SetTitle("Photino Testing")
            .SetBrowserControlInitParameters(browserControlInitParams)
            .LoadRawString("Hello World!");

        window.WaitForClose();
    }
}

I found this flag here (https://peter.sh/experiments/chromium-command-line-switches/). From my understanding, WebView2 uses Chromium and these flags should apply to WebView2.

Nicks182 commented 8 months ago

Sweet! Just tried it and it's working.

if (PhotinoWindow.IsWindowsPlatform) { browserControlInitParams = "--enable-smooth-scrolling"; }

I know it's such a simple thing, but IMO it makes such a big difference for UX.

Now to go through what's new in Photino 2.5 :)

philippjbauer commented 8 months ago

Awesome! Thank you for the response Nick! :)