{"id":22920902,"url":"https://github.com/enusbaum/xamarinexamples.forms.skiasharppanning","last_synced_at":"2026-05-07T11:33:44.676Z","repository":{"id":88397018,"uuid":"122142059","full_name":"enusbaum/XamarinExamples.Forms.SkiaSharpPanning","owner":"enusbaum","description":"Xamarin.Forms example of how to use SkiaSharp to pan and scroll a large image with a fixed size View","archived":false,"fork":false,"pushed_at":"2018-02-20T02:50:14.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T13:46:23.701Z","etag":null,"topics":["csharp","dotnet","skiasharp","xamarin","xamarin-forms","xamarin-ios"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enusbaum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-20T01:20:33.000Z","updated_at":"2022-02-16T09:03:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2f220b9-2adc-43bd-8a60-959cc70e2558","html_url":"https://github.com/enusbaum/XamarinExamples.Forms.SkiaSharpPanning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/enusbaum/XamarinExamples.Forms.SkiaSharpPanning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.SkiaSharpPanning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.SkiaSharpPanning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.SkiaSharpPanning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.SkiaSharpPanning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enusbaum","download_url":"https://codeload.github.com/enusbaum/XamarinExamples.Forms.SkiaSharpPanning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enusbaum%2FXamarinExamples.Forms.SkiaSharpPanning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32735202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","skiasharp","xamarin","xamarin-forms","xamarin-ios"],"created_at":"2024-12-14T07:17:21.879Z","updated_at":"2026-05-07T11:33:44.639Z","avatar_url":"https://github.com/enusbaum.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XamarinExamples.Forms.SkiaSharpPanning\n\nThis repository holds an example of the best way I've been able to come up with to handle panning a drawing/graphic rendered with SkiaSharp. It takes from the Xamarin example of applying custom TouchEffects for Finger Painting and applies it to a 2D surface for panning.\n\nUsing this method allows you to scroll through larger charts/graphics or even handle pannig on a \"zoomed in\" image.\n\nCheers!\n\n# How it works\n\n\n### Xamarin.Forms\n\nIn the Xamarin.Forms project we implement the custom TouchEffects example as described over at the Xamarin documentation ([link](https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/effects/touch-tracking/))\n\n```xml\n\u003cviews:SKCanvasView x:Name=\"canvasChart\" HorizontalOptions=\"FillAndExpand\" VerticalOptions=\"FillAndExpand\" EnableTouchEvents=\"true\" PaintSurface=\"Handle_PaintSurface\"\u003e\n    \u003cviews:SKCanvasView.Effects\u003e\n        \u003ce:TouchEffect TouchAction=\"Handle_TouchAction\" Capture=\"true\" /\u003e\n    \u003c/views:SKCanvasView.Effects\u003e\n\u003c/views:SKCanvasView\u003e\n```\n\nDeltas are calculated by comparing the touch points between \"Moved\" touch events. This allows us to continue aggregation of the total X/Y delta during the move. We then apply this delta to all elements painted to the surface thus giving us the \"panning\" effect\n\n```csharp\nvoid Handle_TouchAction(object sender, TouchActionEventArgs args)\n    {\n        //First touch, just mark the location\n        if (args.Type == TouchActionType.Pressed)\n        {\n            _previousTouchPoint = args.Location;\n            return;\n        }\n        //User is dragging/moving the chart\n        if (args.Type == TouchActionType.Moved)\n        {\n            //Calculate Deltas in the drag\n            var _touchYDelta = (float)Math.Round((_previousTouchPoint.Y - args.Location.Y) * 2, 0);\n            var _touchXDelta = (float)Math.Round((_previousTouchPoint.X - args.Location.X) * 2, 0);\n            //Re-Draw the Chart\n            if (_touchYDelta \u003e= 1 || _touchYDelta \u003c= -1 || _touchXDelta \u003e= 1 || _touchXDelta \u003c= 1)\n            {\n                _YDelta -= _touchYDelta;\n                _XDelta -= _touchXDelta;\n                _previousTouchPoint = args.Location;\n            }\n        }\n        canvasChart.InvalidateSurface();\n    }\n```\n\n### Xamarin.iOS\n\nFor the Xamarin.iOS bit, we simply implement the custom TouchEffect as outlined in the Xamarin documentation.\n\n#### FYI\n\n* You need to have the [EnableTouchEvents](https://developer.xamarin.com/api/property/SkiaSharp.Views.Forms.SKCanvasView.EnableTouchEvents/) set to **TRUE** on the SkiaSharp Canvas in order for the Touch Effects to be invoked.\n\n* Other Xamarin.Forms controls that make use of \"Moved' Touch Effects can interfere with this and cause the drag to be interrupted. An example being the slide out action for a MasterDetail menu. To fix this, you would need to set [IsGestureEnabled](https://developer.xamarin.com/api/property/Xamarin.Forms.MasterDetailPage.IsGestureEnabled/) to **FALSE** on the MasterDetail page.\n\n* A good general rule of thumb when working with Touch Actions and Gestures is to keep track on a page which gestures are used where in order to make sure multiple controls are not going to be conflicting with one another.\n\nCheers!\n\n![Example of Panning](https://d2ffutrenqvap3.cloudfront.net/items/2y2u0X122V32310l2t3v/Screen%20Recording%202018-02-19%20at%2009.34%20PM.gif \"Example of Panning\")","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.skiasharppanning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.skiasharppanning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenusbaum%2Fxamarinexamples.forms.skiasharppanning/lists"}