├── .github └── workflows │ └── main.yml ├── .gitignore ├── Blazor.SVGAnimation.sln ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── docs └── icon.png ├── samples ├── KristofferStrube.Blazor.SVGAnimation.WasmSample │ ├── App.razor │ ├── Confetti │ │ ├── Confetti.razor │ │ ├── ConfettiAnimator.razor │ │ ├── ConfettiOptions.cs │ │ ├── ConfettiOriginMode.cs │ │ ├── ConfettiPiece.cs │ │ ├── ConfettiService.cs │ │ ├── DoubleExtensions.cs │ │ └── IServiceExtensions.cs │ ├── KristofferStrube.Blazor.SVGAnimation.WasmSample.csproj │ ├── Pages │ │ ├── Celebration.razor │ │ ├── Index.razor │ │ └── Loading.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── _Imports.razor │ └── wwwroot │ │ ├── 404.html │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html └── KristofferStrube.Blazor.SVGAnimation.WebAppSample │ ├── Components │ ├── App.razor │ ├── Layout │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── Pages │ │ ├── Celebration.razor │ │ ├── Error.razor │ │ ├── Index.razor │ │ └── Loading.razor │ ├── Routes.razor │ └── _Imports.razor │ ├── Confetti │ ├── Confetti.razor │ ├── ConfettiAnimator.razor │ ├── ConfettiOptions.cs │ ├── ConfettiOriginMode.cs │ ├── ConfettiPiece.cs │ ├── ConfettiService.cs │ ├── DoubleExtensions.cs │ └── IServiceExtensions.cs │ ├── CustomRenderModes.cs │ ├── KristofferStrube.Blazor.SVGAnimation.WebAppSample.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── app.css │ ├── bootstrap │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ └── favicon.png └── src └── KristofferStrube.Blazor.SVGAnimation ├── Extensions ├── IJSRuntimeExtensions.cs └── IServiceCollectionExtensions.cs ├── ISVGAnimationService.cs ├── KristofferStrube.Blazor.SVGAnimation.csproj ├── SVGAnimationElement.InProcess.cs ├── SVGAnimationElement.cs ├── SVGAnimationService.cs └── wwwroot └── KristofferStrube.Blazor.SVGAnimation.js /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: 'Publish application' 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - '**/README.md' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Checkout the code 15 | - uses: actions/checkout@v2 16 | 17 | # Install .NET 8.0 SDK 18 | - name: Setup .NET 8 19 | uses: actions/setup-dotnet@v1 20 | with: 21 | dotnet-version: '8.0.x' 22 | include-prerelease: true 23 | 24 | # Generate the website 25 | - name: Publish 26 | run: dotnet publish samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/KristofferStrube.Blazor.SVGAnimation.WasmSample.csproj --configuration Release --output build 27 | 28 | # Publish the website 29 | - name: GitHub Pages action 30 | if: ${{ github.ref == 'refs/heads/main' }} # Publish only when the push is on main 31 | uses: peaceiris/actions-gh-pages@v3.6.1 32 | with: 33 | github_token: ${{ secrets.PUBLISH_TOKEN }} 34 | publish_branch: gh-pages 35 | publish_dir: build/wwwroot 36 | allow_empty_commit: false 37 | keep_files: false 38 | force_orphan: true 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # Tye 66 | .tye/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.vspscc 97 | *.vssscc 98 | .builds 99 | *.pidb 100 | *.svclog 101 | *.scc 102 | 103 | # Chutzpah Test files 104 | _Chutzpah* 105 | 106 | # Visual C++ cache files 107 | ipch/ 108 | *.aps 109 | *.ncb 110 | *.opendb 111 | *.opensdf 112 | *.sdf 113 | *.cachefile 114 | *.VC.db 115 | *.VC.VC.opendb 116 | 117 | # Visual Studio profiler 118 | *.psess 119 | *.vsp 120 | *.vspx 121 | *.sap 122 | 123 | # Visual Studio Trace Files 124 | *.e2e 125 | 126 | # TFS 2012 Local Workspace 127 | $tf/ 128 | 129 | # Guidance Automation Toolkit 130 | *.gpState 131 | 132 | # ReSharper is a .NET coding add-in 133 | _ReSharper*/ 134 | *.[Rr]e[Ss]harper 135 | *.DotSettings.user 136 | 137 | # TeamCity is a build add-in 138 | _TeamCity* 139 | 140 | # DotCover is a Code Coverage Tool 141 | *.dotCover 142 | 143 | # AxoCover is a Code Coverage Tool 144 | .axoCover/* 145 | !.axoCover/settings.json 146 | 147 | # Coverlet is a free, cross platform Code Coverage Tool 148 | coverage*.json 149 | coverage*.xml 150 | coverage*.info 151 | 152 | # Visual Studio code coverage results 153 | *.coverage 154 | *.coveragexml 155 | 156 | # NCrunch 157 | _NCrunch_* 158 | .*crunch*.local.xml 159 | nCrunchTemp_* 160 | 161 | # MightyMoose 162 | *.mm.* 163 | AutoTest.Net/ 164 | 165 | # Web workbench (sass) 166 | .sass-cache/ 167 | 168 | # Installshield output folder 169 | [Ee]xpress/ 170 | 171 | # DocProject is a documentation generator add-in 172 | DocProject/buildhelp/ 173 | DocProject/Help/*.HxT 174 | DocProject/Help/*.HxC 175 | DocProject/Help/*.hhc 176 | DocProject/Help/*.hhk 177 | DocProject/Help/*.hhp 178 | DocProject/Help/Html2 179 | DocProject/Help/html 180 | 181 | # Click-Once directory 182 | publish/ 183 | 184 | # Publish Web Output 185 | *.[Pp]ublish.xml 186 | *.azurePubxml 187 | # Note: Comment the next line if you want to checkin your web deploy settings, 188 | # but database connection strings (with potential passwords) will be unencrypted 189 | *.pubxml 190 | *.publishproj 191 | 192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 193 | # checkin your Azure Web App publish settings, but sensitive information contained 194 | # in these scripts will be unencrypted 195 | PublishScripts/ 196 | 197 | # NuGet Packages 198 | *.nupkg 199 | # NuGet Symbol Packages 200 | *.snupkg 201 | # The packages folder can be ignored because of Package Restore 202 | **/[Pp]ackages/* 203 | # except build/, which is used as an MSBuild target. 204 | !**/[Pp]ackages/build/ 205 | # Uncomment if necessary however generally it will be regenerated when needed 206 | #!**/[Pp]ackages/repositories.config 207 | # NuGet v3's project.json files produces more ignorable files 208 | *.nuget.props 209 | *.nuget.targets 210 | 211 | # Microsoft Azure Build Output 212 | csx/ 213 | *.build.csdef 214 | 215 | # Microsoft Azure Emulator 216 | ecf/ 217 | rcf/ 218 | 219 | # Windows Store app package directories and files 220 | AppPackages/ 221 | BundleArtifacts/ 222 | Package.StoreAssociation.xml 223 | _pkginfo.txt 224 | *.appx 225 | *.appxbundle 226 | *.appxupload 227 | 228 | # Visual Studio cache files 229 | # files ending in .cache can be ignored 230 | *.[Cc]ache 231 | # but keep track of directories ending in .cache 232 | !?*.[Cc]ache/ 233 | 234 | # Others 235 | ClientBin/ 236 | ~$* 237 | *~ 238 | *.dbmdl 239 | *.dbproj.schemaview 240 | *.jfm 241 | *.pfx 242 | *.publishsettings 243 | orleans.codegen.cs 244 | 245 | # Including strong name files can present a security risk 246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 247 | #*.snk 248 | 249 | # Since there are multiple workflows, uncomment next line to ignore bower_components 250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 251 | #bower_components/ 252 | 253 | # RIA/Silverlight projects 254 | Generated_Code/ 255 | 256 | # Backup & report files from converting an old project file 257 | # to a newer Visual Studio version. Backup files are not needed, 258 | # because we have git ;-) 259 | _UpgradeReport_Files/ 260 | Backup*/ 261 | UpgradeLog*.XML 262 | UpgradeLog*.htm 263 | ServiceFabricBackup/ 264 | *.rptproj.bak 265 | 266 | # SQL Server files 267 | *.mdf 268 | *.ldf 269 | *.ndf 270 | 271 | # Business Intelligence projects 272 | *.rdl.data 273 | *.bim.layout 274 | *.bim_*.settings 275 | *.rptproj.rsuser 276 | *- [Bb]ackup.rdl 277 | *- [Bb]ackup ([0-9]).rdl 278 | *- [Bb]ackup ([0-9][0-9]).rdl 279 | 280 | # Microsoft Fakes 281 | FakesAssemblies/ 282 | 283 | # GhostDoc plugin setting file 284 | *.GhostDoc.xml 285 | 286 | # Node.js Tools for Visual Studio 287 | .ntvs_analysis.dat 288 | node_modules/ 289 | 290 | # Visual Studio 6 build log 291 | *.plg 292 | 293 | # Visual Studio 6 workspace options file 294 | *.opt 295 | 296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 297 | *.vbw 298 | 299 | # Visual Studio LightSwitch build output 300 | **/*.HTMLClient/GeneratedArtifacts 301 | **/*.DesktopClient/GeneratedArtifacts 302 | **/*.DesktopClient/ModelManifest.xml 303 | **/*.Server/GeneratedArtifacts 304 | **/*.Server/ModelManifest.xml 305 | _Pvt_Extensions 306 | 307 | # Paket dependency manager 308 | .paket/paket.exe 309 | paket-files/ 310 | 311 | # FAKE - F# Make 312 | .fake/ 313 | 314 | # CodeRush personal settings 315 | .cr/personal 316 | 317 | # Python Tools for Visual Studio (PTVS) 318 | __pycache__/ 319 | *.pyc 320 | 321 | # Cake - Uncomment if you are using it 322 | # tools/** 323 | # !tools/packages.config 324 | 325 | # Tabs Studio 326 | *.tss 327 | 328 | # Telerik's JustMock configuration file 329 | *.jmconfig 330 | 331 | # BizTalk build output 332 | *.btp.cs 333 | *.btm.cs 334 | *.odx.cs 335 | *.xsd.cs 336 | 337 | # OpenCover UI analysis results 338 | OpenCover/ 339 | 340 | # Azure Stream Analytics local run output 341 | ASALocalRun/ 342 | 343 | # MSBuild Binary and Structured Log 344 | *.binlog 345 | 346 | # NVidia Nsight GPU debugger configuration file 347 | *.nvuser 348 | 349 | # MFractors (Xamarin productivity tool) working folder 350 | .mfractor/ 351 | 352 | # Local History for Visual Studio 353 | .localhistory/ 354 | 355 | # BeatPulse healthcheck temp database 356 | healthchecksdb 357 | 358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 359 | MigrationBackup/ 360 | 361 | # Ionide (cross platform F# VS Code tools) working folder 362 | .ionide/ 363 | 364 | # Fody - auto-generated XML schema 365 | FodyWeavers.xsd 366 | 367 | ## 368 | ## Visual studio for Mac 369 | ## 370 | 371 | 372 | # globs 373 | Makefile.in 374 | *.userprefs 375 | *.usertasks 376 | config.make 377 | config.status 378 | aclocal.m4 379 | install-sh 380 | autom4te.cache/ 381 | *.tar.gz 382 | tarballs/ 383 | test-results/ 384 | 385 | # Mac bundle stuff 386 | *.dmg 387 | *.app 388 | 389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 390 | # General 391 | .DS_Store 392 | .AppleDouble 393 | .LSOverride 394 | 395 | # Icon must end with two \r 396 | Icon 397 | 398 | 399 | # Thumbnails 400 | ._* 401 | 402 | # Files that might appear in the root of a volume 403 | .DocumentRevisions-V100 404 | .fseventsd 405 | .Spotlight-V100 406 | .TemporaryItems 407 | .Trashes 408 | .VolumeIcon.icns 409 | .com.apple.timemachine.donotpresent 410 | 411 | # Directories potentially created on remote AFP share 412 | .AppleDB 413 | .AppleDesktop 414 | Network Trash Folder 415 | Temporary Items 416 | .apdisk 417 | 418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 419 | # Windows thumbnail cache files 420 | Thumbs.db 421 | ehthumbs.db 422 | ehthumbs_vista.db 423 | 424 | # Dump file 425 | *.stackdump 426 | 427 | # Folder config file 428 | [Dd]esktop.ini 429 | 430 | # Recycle Bin used on file shares 431 | $RECYCLE.BIN/ 432 | 433 | # Windows Installer files 434 | *.cab 435 | *.msi 436 | *.msix 437 | *.msm 438 | *.msp 439 | 440 | # Windows shortcuts 441 | *.lnk 442 | 443 | # JetBrains Rider 444 | .idea/ 445 | *.sln.iml 446 | 447 | ## 448 | ## Visual Studio Code 449 | ## 450 | .vscode/* 451 | !.vscode/settings.json 452 | !.vscode/tasks.json 453 | !.vscode/launch.json 454 | !.vscode/extensions.json 455 | -------------------------------------------------------------------------------- /Blazor.SVGAnimation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32422.2 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KristofferStrube.Blazor.SVGAnimation", "src\KristofferStrube.Blazor.SVGAnimation\KristofferStrube.Blazor.SVGAnimation.csproj", "{79BCFFFF-36C5-426B-9E3B-8116ECD32E36}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KristofferStrube.Blazor.SVGAnimation.WasmSample", "samples\KristofferStrube.Blazor.SVGAnimation.WasmSample\KristofferStrube.Blazor.SVGAnimation.WasmSample.csproj", "{D9942C3C-CB70-4D48-9E6E-401FB2B71DAF}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KristofferStrube.Blazor.SVGAnimation.WebAppSample", "samples\KristofferStrube.Blazor.SVGAnimation.WebAppSample\KristofferStrube.Blazor.SVGAnimation.WebAppSample.csproj", "{B4DDB161-AB31-42EC-B6D7-BED669C97EE7}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {79BCFFFF-36C5-426B-9E3B-8116ECD32E36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {79BCFFFF-36C5-426B-9E3B-8116ECD32E36}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {79BCFFFF-36C5-426B-9E3B-8116ECD32E36}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {79BCFFFF-36C5-426B-9E3B-8116ECD32E36}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D9942C3C-CB70-4D48-9E6E-401FB2B71DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D9942C3C-CB70-4D48-9E6E-401FB2B71DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D9942C3C-CB70-4D48-9E6E-401FB2B71DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D9942C3C-CB70-4D48-9E6E-401FB2B71DAF}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {B4DDB161-AB31-42EC-B6D7-BED669C97EE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {B4DDB161-AB31-42EC-B6D7-BED669C97EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {B4DDB161-AB31-42EC-B6D7-BED669C97EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {B4DDB161-AB31-42EC-B6D7-BED669C97EE7}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {A94232FD-AEC9-486E-95EC-27F20C51CBC1} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | 9 | ## [0.2.0] - 2023-12-04 10 | ### Added 11 | - Added support for Blazor Server in all existing methods. 12 | - Added correct wrapping for events via the `AddOnBeginEventListenerAsync`, `AddOnEndEventListenerAsync`, and `AddOnRepeatEventListenerAsync` methods on the `SVGAnimationElement` class. 13 | - Added a way to remove listeners via the `RemoveOnBeginEventListenerAsync`, `RemoveOnEndEventListenerAsync`, and `RemoveOnRepeatEventListenerAsync` methods on the `SVGAnimationElement` class. 14 | - Added `SVGAnimationElementInProcess` class which surfaces WASM-only in-process variants of all methods available in `SVGAnimationElement`. 15 | ### Changed 16 | - Changed it so that `SVGAnimationElement` now inherits from the `EventTarget` wrapper from the `Blazor.DOM` library to be closer to the API specification. 17 | ### Deprecated 18 | - The `SVGAnimationService` that was previously used for creating wrappers is marked as obsolete as it doesn't follow our current pattern for creating wrapper instances. Use the `SVGAnimationElement.CreateAsync` method instead. 19 | - The In-process accessor for `TargetElement` on `SVGAnimationElement` has been marked as obsolete as it is not supported in Blazor Server. 20 | - The `SubscribeToBeginAsync`, `SubscribeToEndAsync`, and `SubscribeToRepeatAsync` methods on `SVGAnimationElement` have been marked as obsolete as they did not give any way to remove the event listeners they added. 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | Contributing includes many different actions. It is not only writing code. Contributions like discussing solutions in open issues are easily as valuable as contributing code as we can then find the best solution with the perspective of multiple people. 3 | 4 | ## Bugs and feature requests 5 | If you find any bugs in the project or have requests for features, then please [Open a new Issue](https://github.com/KristofferStrube/Blazor.SVGAnimation/issues/new). 6 | 7 | ## Contributing Code and Samples 8 | Before you contribute to the project, you will need to get confirmation from the library author that the contribution is welcome. 9 | This can help align the scope of the contribution so that you and the author agree on the solution and how you ensure the change is maintainable with the existing users in mind. 10 | Once you are ready to start coding try to follow these code guidelines: 11 | - Make a fork of the current `main` branch. 12 | - Follow the existing coding conventions used in the project. This includes tab style, naming conventions, etc. 13 | - If your contribution is a new feature, try to add a demo that demonstrates how this will be used in the sample project. 14 | - Any code or sample you share as a part of the resulting Pull Request should fall under the MIT license agreement. 15 | - You don't need to update the version number of the project as the maintainer will do this when making the next release after the Pull Request has been merged. 16 | - Keep your Pull Request to the point. I.e., if your Pull Request is related to fixing a bug then try not to touch any other files than the ones related to that issue as this will make the chance of the PR being merged without change requests more likely. 17 | 18 | ## Submitting a Pull Request 19 | If you don't know what a pull request is, read this article: https://help.github.com/articles/using-pull-requests. Make sure the repository can be built and that the related sample project still works as intended. It is also a good idea to familiarize yourself with the project workflow and our coding conventions. 20 | 21 | ## Ensuring that your contribution will be accepted 22 | You might also read these two blog posts on contributing code: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik. These blog posts highlight good open-source collaboration etiquette and help align expectations between you and us. 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kristoffer Strube 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](/LICENSE) 2 | [![GitHub issues](https://img.shields.io/github/issues/KristofferStrube/Blazor.SVGAnimation)](https://github.com/KristofferStrube/Blazor.SVGAnimation/issues) 3 | [![GitHub forks](https://img.shields.io/github/forks/KristofferStrube/Blazor.SVGAnimation)](https://github.com/KristofferStrube/Blazor.SVGAnimation/network/members) 4 | [![GitHub stars](https://img.shields.io/github/stars/KristofferStrube/Blazor.SVGAnimation)](https://github.com/KristofferStrube/Blazor.SVGAnimation/stargazers) 5 | 6 | [![NuGet Downloads (official NuGet)](https://img.shields.io/nuget/dt/KristofferStrube.Blazor.SVGAnimation?label=NuGet%20Downloads)](https://www.nuget.org/packages/KristofferStrube.Blazor.SVGAnimation/) 7 | 8 | # Introduction 9 | A Blazor WASM wrapper for the SVG Animation browser API. 10 | 11 | With the wrapper, we can listen to the `begin`, `end`, and `repeat` events, see the status of SVG Animations, and start and stop animations at specific times from Blazor. 12 | 13 | The specs for the API can be found at https://svgwg.org/specs/animations/#IDL 14 | 15 | ## Demo 16 | The sample project can be demoed at https://kristofferstrube.github.io/Blazor.SVGAnimation/ 17 | 18 | On each page, you can find the corresponding code for the example in the top right corner. 19 | 20 | # Getting Started 21 | ## Prerequisites 22 | You need to install .NET 7.0 or newer to use the library. 23 | 24 | [Download .NET 7](https://dotnet.microsoft.com/download/dotnet/7.0) 25 | 26 | ## Installation 27 | You can install the package via Nuget with the Package Manager in your IDE or using the command line: 28 | ```bash 29 | dotnet add package KristofferStrube.Blazor.SVGAnimation 30 | ``` 31 | 32 | # Usage 33 | The package can be used in all Blazor projects. 34 | ## Import 35 | You also need to reference the package in order to use it in your pages. This can be done in `_Import.razor` by adding the following. 36 | ```razor 37 | @using KristofferStrube.Blazor.SVGAnimation 38 | ``` 39 | 40 | ## Creating wrapper instances 41 | The primary part of this library is a wrapper class for `SVGAnimationElement`s which can be instantiated from your code using the static `CreateAsync` methods on the wrapper class. 42 | ```razor 43 | @inject IJSRuntime JSRuntime 44 | 45 | 46 | 50 | 55 | 56 | 57 | 58 | @code { 59 | private ElementReference colorAnimationElementReference = default!; 60 | 61 | private async void SquareClicked() 62 | { 63 | SVGAnimationElement colorAnimationElement = await SVGAnimationElement.CreateAsync(JSRuntime, colorAnimationElementReference); 64 | await colorAnimationElement.BeginElementAsync(); 65 | } 66 | } 67 | ``` 68 | You can also use a `SVGAnimationElement` to listen for the `beginEvent`, `endEvent`, and `repeatEvent` events. The following is an example of listening for when a repeat event happens. 69 | ```razor 70 | @using KristofferStrube.Blazor.DOM 71 | @implements IAsyncDisposable 72 | @inject IJSRuntime JSRuntime 73 | 74 | Number of repeats: @repeats 75 |
76 | 77 | 81 | 87 | 88 | 89 | 90 | @code { 91 | private ElementReference colorAnimationElementReference = default!; 92 | private SVGAnimationElement colorAnimationElement = default!; 93 | private EventListener repeatListener = default!; 94 | private int repeats = 0; 95 | 96 | protected override async Task OnAfterRenderAsync(bool firstRender) 97 | { 98 | if (!firstRender) return; 99 | colorAnimationElement = await SVGAnimationElement.CreateAsync(JSRuntime, colorAnimationElementReference); 100 | repeatListener = await colorAnimationElement.AddOnRepeatEventListenerAsync(_ => 101 | { 102 | repeats++; 103 | StateHasChanged(); 104 | return Task.CompletedTask; 105 | }); 106 | } 107 | 108 | private async void SquareClicked() 109 | { 110 | await colorAnimationElement.BeginElementAsync(); 111 | } 112 | 113 | public async ValueTask DisposeAsync() 114 | { 115 | await colorAnimationElement.RemoveOnRepeatEventListenerAsync(repeatListener); 116 | } 117 | } 118 | ``` 119 | 120 | # Issues 121 | Feel free to open issues on the repository if you find any errors with the package or have wishes for features. 122 | 123 | # Related articles 124 | This repository was built with inspiration and help from the following series of articles: 125 | 126 | - [Wrapping JavaScript libraries in Blazor WebAssembly/WASM](https://blog.elmah.io/wrapping-javascript-libraries-in-blazor-webassembly-wasm/) 127 | - [Call anonymous C# functions from JS in Blazor WASM](https://blog.elmah.io/call-anonymous-c-functions-from-js-in-blazor-wasm/) 128 | - [Using JS Object References in Blazor WASM to wrap JS libraries](https://blog.elmah.io/using-js-object-references-in-blazor-wasm-to-wrap-js-libraries/) 129 | - [Blazor WASM 404 error and fix for GitHub Pages](https://blog.elmah.io/blazor-wasm-404-error-and-fix-for-github-pages/) 130 | - [How to fix Blazor WASM base path problems](https://blog.elmah.io/how-to-fix-blazor-wasm-base-path-problems/) 131 | -------------------------------------------------------------------------------- /docs/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/docs/icon.png -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/Confetti.razor: -------------------------------------------------------------------------------- 1 | @using KristofferStrube.Blazor.DOM.Extensions 2 | @using Microsoft.JSInterop 3 | @implements IDisposable 4 | 5 | 6 | @foreach (var confettiPiece in confettiPieces) 7 | { 8 | 9 | } 10 | 11 | 12 | @code { 13 | private double width; 14 | private double height; 15 | private bool playing = false; 16 | 17 | [Inject] 18 | public required IJSRuntime JSRuntime { get; set; } 19 | 20 | [Inject] 21 | public required ConfettiService ConfettiService { get; set; } 22 | 23 | List confettiPieces = new(); 24 | 25 | protected override async Task OnAfterRenderAsync(bool firstRender) 26 | { 27 | if (!firstRender) return; 28 | 29 | ConfettiService.Activated += HandleActivated; 30 | 31 | IJSObjectReference windowReference = await JSRuntime.InvokeAsync("window.valueOf"); 32 | 33 | var helper = await JSRuntime.GetHelperAsync(); 34 | width = await helper.InvokeAsync("getAttribute", windowReference, "innerWidth"); 35 | height = await helper.InvokeAsync("getAttribute", windowReference, "innerHeight"); 36 | } 37 | 38 | public record ClientRect(double x, double y, double width, double height); 39 | 40 | public async void HandleActivated(object? sender, ConfettiOptions options) 41 | { 42 | if (playing) return; 43 | 44 | (double X, double Y)? originPosition = null; 45 | if (options.Origin is { } origin) 46 | { 47 | var helper = await JSRuntime.GetHelperAsync(); 48 | var jSInstance = await helper.InvokeAsync("getJSReference", origin); 49 | var client = await jSInstance.InvokeAsync("getBoundingClientRect"); 50 | originPosition = (X: client.x + client.width / 2, Y: client.y + client.height / 2); 51 | } 52 | 53 | confettiPieces = Enumerable 54 | .Range(0, options.Pieces) 55 | .Select(i => 56 | new ConfettiPiece( 57 | options.Colors[Random.Shared.Next(options.Colors.Length)], 58 | options.Milliseconds + (int)((Random.Shared.NextDouble() * 2 - 1) * options.VariationInMilliseconds), 59 | options.Mode switch 60 | { 61 | ConfettiOriginMode.FromBottomCenter => FromBottomCenterPositions(), 62 | ConfettiOriginMode.FromElement when originPosition is not null => FromElementPositions(originPosition.Value), 63 | _ => FromBottomCenterPositions() 64 | } 65 | ) 66 | ).ToList(); 67 | playing = true; 68 | StateHasChanged(); 69 | await Task.Delay(options.Milliseconds + options.VariationInMilliseconds); 70 | confettiPieces = new(); 71 | playing = false; 72 | StateHasChanged(); 73 | } 74 | 75 | private (double X, double Y)[] FromBottomCenterPositions() 76 | { 77 | var x = Random.Shared.NextDouble() - 0.5; 78 | var y = Random.Shared.NextDouble(); 79 | var end = Random.Shared.NextDouble(); 80 | return [(width / 2, height), (width / 2 + x * width / 3 * 2, height / 2 - y * height / 2), (width / 2 + x * width / 3 * 4, height + end * height / 3)]; 81 | } 82 | 83 | private (double X, double Y)[] FromElementPositions((double x, double y) originPosition) 84 | { 85 | var x = Random.Shared.NextDouble() - 0.5; 86 | var y = Random.Shared.NextDouble(); 87 | var end = Random.Shared.NextDouble(); 88 | return [originPosition, (originPosition.x + x * width / 3 * 2, height / 2 - y * height / 2), (originPosition.x + x * width / 3 * 4, height + end * height / 3)]; 89 | } 90 | 91 | public void Dispose() 92 | { 93 | ConfettiService.Activated -= HandleActivated; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/ConfettiAnimator.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.JSInterop 2 | 3 | 8 | 9 | 10 | @code { 11 | protected ElementReference animateReference { get; set; } 12 | protected SVGAnimationElement? animationElement; 13 | 14 | [Inject] 15 | public required IJSRuntime JSRuntime { get; set; } 16 | 17 | [Parameter, EditorRequired] 18 | public required ConfettiPiece ConfettiPiece { get; set; } 19 | 20 | protected override async Task OnAfterRenderAsync(bool firstRender) 21 | { 22 | if (!firstRender) return; 23 | 24 | animationElement = await SVGAnimationElement.CreateAsync(JSRuntime, animateReference); 25 | 26 | await animationElement.BeginElementAsync(); 27 | await animationElement.EndElementAtAsync(ConfettiPiece.Milliseconds); 28 | } 29 | 30 | private string SmoothPath((double X, double Y)[] points) 31 | { 32 | // Parameter for smoothness of path in interval [0, 0.5] 33 | double smoothness = 1.0 / 3.0; 34 | 35 | var result = ""; 36 | if (points.Length >= 2) 37 | { 38 | result = $"M {points[0].X.AsString()} {points[0].Y.AsString()} "; 39 | for (int i = 1; i < points.Length - 1; i++) 40 | { 41 | result += $"S {(points[i - 1].X * smoothness / 2 + points[i].X - points[i + 1].X * smoothness / 2).AsString()} {(points[i - 1].Y * smoothness / 2 + points[i].Y - points[i + 1].Y * smoothness / 2).AsString()} {points[i].X.AsString()} {points[i].Y.AsString()} "; 42 | } 43 | result += $"S {(points[^2].X * smoothness + points[^1].X * (1 - smoothness)).AsString()} {(points[^2].Y * smoothness + points[^1].Y * (1 - smoothness)).AsString()} {points[^1].X.AsString()} {points[^1].Y.AsString()} "; 44 | } 45 | return result; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/ConfettiOptions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 4 | 5 | public class ConfettiOptions : EventArgs 6 | { 7 | public int Pieces { get; set; } = 300; 8 | 9 | public int Milliseconds { get; set; } = 1000; 10 | 11 | public int VariationInMilliseconds { get; set; } = 200; 12 | 13 | public string[] Colors { get; set; } = ["#F4F", "#44F", "#4F4", "#F44", "#9F0"]; 14 | 15 | public ConfettiOriginMode Mode { get; set; } = ConfettiOriginMode.FromBottomCenter; 16 | 17 | public ElementReference? Origin { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/ConfettiOriginMode.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 2 | 3 | public enum ConfettiOriginMode 4 | { 5 | FromBottomCenter, 6 | FromElement 7 | } 8 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/ConfettiPiece.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 2 | 3 | public record struct ConfettiPiece(string Color, int Milliseconds, (double X, double Y)[] Positions); -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/ConfettiService.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 2 | 3 | public class ConfettiService 4 | { 5 | public event ActivatedEventHandler Activated; 6 | 7 | public void Activate(ConfettiOptions options) 8 | { 9 | Activated?.Invoke(this, options); 10 | } 11 | 12 | public delegate void ActivatedEventHandler(Object sender, ConfettiOptions e); 13 | } 14 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/DoubleExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 4 | 5 | public static class DoubleExtensions 6 | { 7 | public static string AsString(this double d) => d.ToString(CultureInfo.InvariantCulture); 8 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Confetti/IServiceExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 2 | 3 | public static class IServiceExtensions 4 | { 5 | public static IServiceCollection AddConfettiService(this IServiceCollection serviceCollection) 6 | { 7 | return serviceCollection.AddScoped(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/KristofferStrube.Blazor.SVGAnimation.WasmSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 12 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Pages/Celebration.razor: -------------------------------------------------------------------------------- 1 | @page "/Celebration" 2 | @using KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti 3 | @inject IJSRuntime JSRuntime 4 | 5 | Blazor.SVGAnimation - Celebration 6 | 7 | 8 |
9 | 10 | 11 | @code { 12 | private ElementReference button; 13 | 14 | [Inject] 15 | public required ConfettiService ConfettiService { get; set; } 16 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using KristofferStrube.Blazor.DOM 3 | @implements IDisposable 4 | @inject IJSRuntime JSRuntime 5 | 6 | Blazor.SVGAnimation - Begin Animation 7 | 8 |

Click the paper to begin a SVG Animation

9 | 10 | 11 | 19 | 24 | 30 | 36 | 37 | 38 | 41 | 42 | @code { 43 | protected ElementReference dataAnimationElementReference { get; set; } 44 | protected ElementReference colorAnimationElementReference { get; set; } 45 | protected SVGAnimationElementInProcess dataAnimation = default!; 46 | protected SVGAnimationElement colorAnimation = default!; 47 | protected EventListenerInProcess beginEventListener = default!; 48 | protected EventListenerInProcess endEventListener = default!; 49 | protected EventListenerInProcess repeatEventListener = default!; 50 | protected string log = ""; 51 | 52 | protected override async Task OnAfterRenderAsync(bool firstRender) 53 | { 54 | if (!firstRender) return; 55 | 56 | dataAnimation = await SVGAnimationElementInProcess.CreateAsync(JSRuntime, dataAnimationElementReference); 57 | colorAnimation = await SVGAnimationElement.CreateAsync(JSRuntime, colorAnimationElementReference); 58 | 59 | beginEventListener = await dataAnimation.AddOnBeginEventListenerAsync(_ => 60 | { 61 | log += "Begin event fired\n"; 62 | StateHasChanged(); 63 | }); 64 | endEventListener = await dataAnimation.AddOnEndEventListenerAsync(_ => 65 | { 66 | log += "End event fired\n"; 67 | StateHasChanged(); 68 | }); 69 | repeatEventListener = await dataAnimation.AddOnRepeatEventListenerAsync(_ => 70 | { 71 | log += "Repeat event fired\n"; 72 | StateHasChanged(); 73 | }); 74 | } 75 | 76 | private async Task PaperClicked() 77 | { 78 | dataAnimation.BeginElement(); 79 | await colorAnimation.BeginElementAsync(); 80 | } 81 | 82 | public void Dispose() 83 | { 84 | dataAnimation.RemoveOnBeginEventListener(beginEventListener); 85 | dataAnimation.RemoveOnEndEventListener(endEventListener); 86 | dataAnimation.RemoveOnRepeatEventListener(repeatEventListener); 87 | } 88 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Pages/Loading.razor: -------------------------------------------------------------------------------- 1 | @page "/Loading" 2 | @using KristofferStrube.Blazor.DOM 3 | @implements IAsyncDisposable 4 | @inject IJSRuntime JSRuntime 5 | 6 | Blazor.SVGAnimation - Loading Animation 7 |

We can begin an animation, have it run indefinite, and end it at a full cycle to have a nice stop

8 | 9 | @switch (Status) 10 | { 11 | case AnimationStatus.Still: 12 | 13 | break; 14 | case AnimationStatus.Running: 15 | 16 | break; 17 | case AnimationStatus.Stopping: 18 | 19 | break; 20 | } 21 |
22 | 23 | 24 | 25 | 31 | 32 | 33 | 41 | 42 | 43 | 44 | @code { 45 | protected ElementReference arrowAnimateElement { get; set; } 46 | protected SVGAnimationElement arrowAnimation = default!; 47 | protected EventListener beginEventListener = default!; 48 | protected EventListener endEventListener = default!; 49 | protected AnimationStatus Status = AnimationStatus.Still; 50 | protected float animationTime = 2f; 51 | 52 | protected override async Task OnAfterRenderAsync(bool firstRender) 53 | { 54 | if (!firstRender) return; 55 | 56 | arrowAnimation = await SVGAnimationElement.CreateAsync(JSRuntime, arrowAnimateElement); 57 | 58 | beginEventListener = await arrowAnimation.AddOnBeginEventListenerAsync(_ => 59 | { 60 | Status = AnimationStatus.Running; 61 | StateHasChanged(); 62 | return Task.CompletedTask; 63 | }); 64 | endEventListener = await arrowAnimation.AddOnEndEventListenerAsync(_ => 65 | { 66 | Status = AnimationStatus.Still; 67 | StateHasChanged(); 68 | return Task.CompletedTask; 69 | }); 70 | } 71 | 72 | private async void StartAnimation() 73 | { 74 | if (Status is not AnimationStatus.Still) 75 | { 76 | return; 77 | } 78 | await arrowAnimation.BeginElementAsync(); 79 | } 80 | 81 | private async void EndAnimation() 82 | { 83 | if (Status is not AnimationStatus.Running) 84 | { 85 | return; 86 | } 87 | Status = AnimationStatus.Stopping; 88 | StateHasChanged(); 89 | var startTime = await arrowAnimation.GetStartTimeAsync(); 90 | var timeInPeriod = (await arrowAnimation.GetCurrentTimeAsync() - startTime) % animationTime; 91 | await arrowAnimation.EndElementAtAsync(animationTime - timeInPeriod); 92 | } 93 | 94 | protected enum AnimationStatus 95 | { 96 | Still, 97 | Running, 98 | Stopping 99 | } 100 | 101 | public async ValueTask DisposeAsync() 102 | { 103 | await arrowAnimation.RemoveOnBeginEventListenerAsync(beginEventListener); 104 | await arrowAnimation.RemoveOnEndEventListenerAsync(endEventListener); 105 | } 106 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Program.cs: -------------------------------------------------------------------------------- 1 | using KristofferStrube.Blazor.SVGAnimation.WasmSample; 2 | using KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti; 3 | using Microsoft.AspNetCore.Components.Web; 4 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 5 | 6 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 7 | builder.RootComponents.Add("#app"); 8 | builder.RootComponents.Add("head::after"); 9 | 10 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 11 | 12 | builder.Services.AddConfettiService(); 13 | 14 | await builder.Build().RunAsync(); 15 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:62944", 7 | "sslPort": 44380 8 | } 9 | }, 10 | "profiles": { 11 | "KristofferStrube.Blazor.SVGAnimation.WasmSample": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "https://localhost:7294;http://localhost:5097", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @using KristofferStrube.Blazor.SVGAnimation.WasmSample.Confetti 2 | @inherits LayoutComponentBase 3 | @inject NavigationManager NavigationManager 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 | 14 | 15 |
16 | 17 |
18 | @Body 19 |
20 |
21 |
22 | 23 | 24 | 25 | @code { 26 | private string relativeUri => NavigationManager.ToBaseRelativePath(NavigationManager.Uri); 27 | 28 | protected string page => (string.IsNullOrEmpty(relativeUri) ? "Index" : relativeUri) + ".razor"; 29 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row.auth ::deep a:first-child { 72 | flex: 1; 73 | text-align: right; 74 | width: 0; 75 | } 76 | 77 | .top-row, article { 78 | padding-left: 2rem !important; 79 | padding-right: 1.5rem !important; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 31 |
32 | 33 | @code { 34 | private bool collapseNavMenu = true; 35 | 36 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 37 | 38 | private void ToggleNavMenu() 39 | { 40 | collapseNavMenu = !collapseNavMenu; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using KristofferStrube.Blazor.SVGAnimation.WasmSample 10 | @using KristofferStrube.Blazor.SVGAnimation.WasmSample.Shared 11 | @using System.Globalization -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/404.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Blazor SVG Editor Redirect 6 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .content { 22 | padding-top: 1.1rem; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | .blazor-error-boundary { 57 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 58 | padding: 1rem 1rem 1rem 3.7rem; 59 | color: white; 60 | } 61 | 62 | .blazor-error-boundary::after { 63 | content: "An error has occurred." 64 | } 65 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/favicon.ico -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WasmSample/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KristofferStrube.Blazor.SVGAnimation.WasmSample 8 | 9 | 10 | 32 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
Loading...
50 | 51 |
52 | An unhandled error has occurred. 53 | Reload 54 | 🗙 55 |
56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @using KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti 2 | @inherits LayoutComponentBase 3 | @inject NavigationManager NavigationManager 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 | 14 | 15 |
16 | 17 |
18 | @Body 19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 | An unhandled error has occurred. 27 | Reload 28 | 🗙 29 |
30 | 31 | @code { 32 | private string relativeUri => NavigationManager.ToBaseRelativePath(NavigationManager.Uri); 33 | 34 | protected string page => (string.IsNullOrEmpty(relativeUri) ? "Index" : relativeUri) + ".razor"; 35 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | 79 | #blazor-error-ui { 80 | background: lightyellow; 81 | bottom: 0; 82 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 83 | display: none; 84 | left: 0; 85 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 86 | position: fixed; 87 | width: 100%; 88 | z-index: 1000; 89 | } 90 | 91 | #blazor-error-ui .dismiss { 92 | cursor: pointer; 93 | position: absolute; 94 | right: 0.75rem; 95 | top: 0.5rem; 96 | } 97 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 28 | 29 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | appearance: none; 3 | cursor: pointer; 4 | width: 3.5rem; 5 | height: 2.5rem; 6 | color: white; 7 | position: absolute; 8 | top: 0.5rem; 9 | right: 1rem; 10 | border: 1px solid rgba(255, 255, 255, 0.1); 11 | background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1); 12 | } 13 | 14 | .navbar-toggler:checked { 15 | background-color: rgba(255, 255, 255, 0.5); 16 | } 17 | 18 | .top-row { 19 | height: 3.5rem; 20 | background-color: rgba(0,0,0,0.4); 21 | } 22 | 23 | .navbar-brand { 24 | font-size: 1.1rem; 25 | } 26 | 27 | .bi { 28 | display: inline-block; 29 | position: relative; 30 | width: 1.25rem; 31 | height: 1.25rem; 32 | margin-right: 0.75rem; 33 | top: -1px; 34 | background-size: cover; 35 | } 36 | 37 | .bi-house-door-fill-nav-menu { 38 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 39 | } 40 | 41 | .bi-reload-nav-menu { 42 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 8 8'%3E%3Cpath fill-rule='evenodd' d='M4 0C1.8 0 0 1.8 0 4s1.8 4 4 4c1.1 0 2.12-.43 2.84-1.16l-.72-.72c-.54.54-1.29.88-2.13.88c-1.66 0-3-1.34-3-3s1.34-3 3-3c.83 0 1.55.36 2.09.91L4.99 3h3V0L6.8 1.19C6.08.47 5.09 0 3.99 0'/%3E%3C/svg%3E"); 43 | } 44 | 45 | .nav-item { 46 | font-size: 0.9rem; 47 | padding-bottom: 0.5rem; 48 | } 49 | 50 | .nav-item:first-of-type { 51 | padding-top: 1rem; 52 | } 53 | 54 | .nav-item:last-of-type { 55 | padding-bottom: 1rem; 56 | } 57 | 58 | .nav-item ::deep .nav-link { 59 | color: #d7d7d7; 60 | background: none; 61 | border: none; 62 | border-radius: 4px; 63 | height: 3rem; 64 | display: flex; 65 | align-items: center; 66 | line-height: 3rem; 67 | width: 100%; 68 | } 69 | 70 | .nav-item ::deep a.active { 71 | background-color: rgba(255,255,255,0.37); 72 | color: white; 73 | } 74 | 75 | .nav-item ::deep .nav-link:hover { 76 | background-color: rgba(255,255,255,0.1); 77 | color: white; 78 | } 79 | 80 | .nav-scrollable { 81 | display: none; 82 | } 83 | 84 | .navbar-toggler:checked ~ .nav-scrollable { 85 | display: block; 86 | } 87 | 88 | @media (min-width: 641px) { 89 | .navbar-toggler { 90 | display: none; 91 | } 92 | 93 | .nav-scrollable { 94 | /* Never collapse the sidebar for wide screens */ 95 | display: block; 96 | 97 | /* Allow sidebar to scroll for tall menus */ 98 | height: calc(100vh - 3.5rem); 99 | overflow-y: auto; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Pages/Celebration.razor: -------------------------------------------------------------------------------- 1 | @page "/Celebration" 2 | @using KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti 3 | @rendermode InteractiveServer 4 | @inject IJSRuntime JSRuntime 5 | 6 | Blazor.SVGAnimation - Celebration 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | @code { 15 | private ElementReference button; 16 | 17 | [Inject] 18 | public required ConfettiService ConfettiService { get; set; } 19 | 20 | public void ConfettiFromBottom() => ConfettiService.Activate(new()); 21 | 22 | public void ConfettiFromButton() => 23 | ConfettiService.Activate(new() { 24 | Mode = ConfettiOriginMode.FromElement, 25 | Origin = button 26 | }); 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 | Error 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (ShowRequestId) 10 | { 11 |

12 | Request ID: @RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @rendermode InteractiveServer 3 | @using KristofferStrube.Blazor.DOM 4 | @implements IAsyncDisposable 5 | @inject IJSRuntime JSRuntime 6 | 7 | Blazor.SVGAnimation - Begin Animation 8 | 9 |

Click the paper to begin a SVG Animation

10 | 11 | 12 | 20 | 25 | 31 | 37 | 38 | 39 | 42 | 43 | @code { 44 | protected ElementReference dataAnimationElementReference { get; set; } 45 | protected ElementReference colorAnimationElementReference { get; set; } 46 | protected SVGAnimationElement dataAnimation = default!; 47 | protected SVGAnimationElement colorAnimation = default!; 48 | protected EventListener beginEventListener = default!; 49 | protected EventListener endEventListener = default!; 50 | protected EventListener repeatEventListener = default!; 51 | protected string log = ""; 52 | 53 | protected override async Task OnAfterRenderAsync(bool firstRender) 54 | { 55 | if (!firstRender) return; 56 | 57 | dataAnimation = await SVGAnimationElement.CreateAsync(JSRuntime, dataAnimationElementReference); 58 | colorAnimation = await SVGAnimationElement.CreateAsync(JSRuntime, colorAnimationElementReference); 59 | 60 | beginEventListener = await dataAnimation.AddOnBeginEventListenerAsync(_ => 61 | { 62 | log += "Begin event fired\n"; 63 | StateHasChanged(); 64 | return Task.CompletedTask; 65 | }); 66 | endEventListener = await dataAnimation.AddOnEndEventListenerAsync(_ => 67 | { 68 | log += "End event fired\n"; 69 | StateHasChanged(); 70 | return Task.CompletedTask; 71 | }); 72 | repeatEventListener = await dataAnimation.AddOnRepeatEventListenerAsync(_ => 73 | { 74 | log += "Repeat event fired\n"; 75 | StateHasChanged(); 76 | return Task.CompletedTask; 77 | }); 78 | } 79 | 80 | private async Task PaperClicked() 81 | { 82 | await dataAnimation.BeginElementAsync(); 83 | await colorAnimation.BeginElementAsync(); 84 | } 85 | 86 | public async ValueTask DisposeAsync() 87 | { 88 | await dataAnimation.RemoveOnBeginEventListenerAsync(beginEventListener); 89 | await dataAnimation.RemoveOnBeginEventListenerAsync(endEventListener); 90 | await dataAnimation.RemoveOnBeginEventListenerAsync(repeatEventListener); 91 | } 92 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Pages/Loading.razor: -------------------------------------------------------------------------------- 1 | @page "/Loading" 2 | @rendermode InteractiveServer 3 | @using KristofferStrube.Blazor.DOM 4 | @implements IAsyncDisposable 5 | @inject IJSRuntime JSRuntime 6 | 7 | Blazor.SVGAnimation - Loading Animation 8 |

We can begin an animation, have it run indefinite, and end it at a full cycle to have a nice stop

9 | 10 | @switch (Status) 11 | { 12 | case AnimationStatus.Still: 13 | 14 | break; 15 | case AnimationStatus.Running: 16 | 17 | break; 18 | case AnimationStatus.Stopping: 19 | 20 | break; 21 | } 22 |
23 | 24 | 25 | 26 | 32 | 33 | 34 | 42 | 43 | 44 | 45 | @code { 46 | protected ElementReference arrowAnimateElement { get; set; } 47 | protected SVGAnimationElement? arrowAnimation; 48 | protected EventListener beginEventListener = default!; 49 | protected EventListener endEventListener = default!; 50 | protected AnimationStatus Status = AnimationStatus.Still; 51 | protected float animationTime = 2f; 52 | 53 | protected override async Task OnAfterRenderAsync(bool firstRender) 54 | { 55 | if (!firstRender) return; 56 | 57 | arrowAnimation = await SVGAnimationElement.CreateAsync(JSRuntime, arrowAnimateElement); 58 | 59 | beginEventListener = await arrowAnimation.AddOnBeginEventListenerAsync(_ => 60 | { 61 | Status = AnimationStatus.Running; 62 | StateHasChanged(); 63 | return Task.CompletedTask; 64 | }); 65 | endEventListener = await arrowAnimation.AddOnEndEventListenerAsync(_ => 66 | { 67 | Status = AnimationStatus.Still; 68 | StateHasChanged(); 69 | return Task.CompletedTask; 70 | }); 71 | } 72 | 73 | private async void StartAnimation() 74 | { 75 | if (Status is not AnimationStatus.Still || arrowAnimation is null) 76 | { 77 | return; 78 | } 79 | await arrowAnimation.BeginElementAsync(); 80 | } 81 | 82 | private async void EndAnimation() 83 | { 84 | if (Status is not AnimationStatus.Running || arrowAnimation is null) 85 | { 86 | return; 87 | } 88 | Status = AnimationStatus.Stopping; 89 | StateHasChanged(); 90 | var startTime = await arrowAnimation.GetStartTimeAsync(); 91 | var timeInPeriod = (await arrowAnimation.GetCurrentTimeAsync() - startTime) % animationTime; 92 | await arrowAnimation.EndElementAtAsync(animationTime - timeInPeriod); 93 | } 94 | 95 | protected enum AnimationStatus 96 | { 97 | Still, 98 | Running, 99 | Stopping 100 | } 101 | 102 | public async ValueTask DisposeAsync() 103 | { 104 | if (arrowAnimation is null) return; 105 | 106 | await arrowAnimation.RemoveOnBeginEventListenerAsync(beginEventListener); 107 | await arrowAnimation.RemoveOnEndEventListenerAsync(endEventListener); 108 | } 109 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using KristofferStrube.Blazor.SVGAnimation.WebAppSample 10 | @using KristofferStrube.Blazor.SVGAnimation.WebAppSample.Components 11 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/Confetti.razor: -------------------------------------------------------------------------------- 1 | @using KristofferStrube.Blazor.DOM.Extensions 2 | @using Microsoft.JSInterop 3 | @implements IDisposable 4 | 5 | 6 | @foreach (var confettiPiece in confettiPieces) 7 | { 8 | 9 | } 10 | 11 | 12 | @code { 13 | private double width; 14 | private double height; 15 | private bool playing = false; 16 | 17 | [Inject] 18 | public required IJSRuntime JSRuntime { get; set; } 19 | 20 | [Inject] 21 | public required ConfettiService ConfettiService { get; set; } 22 | 23 | List confettiPieces = new(); 24 | 25 | protected override async Task OnAfterRenderAsync(bool firstRender) 26 | { 27 | if (!firstRender) return; 28 | 29 | ConfettiService.Activated += HandleActivated; 30 | 31 | IJSObjectReference windowReference = await JSRuntime.InvokeAsync("window.valueOf"); 32 | 33 | var helper = await JSRuntime.GetHelperAsync(); 34 | width = await helper.InvokeAsync("getAttribute", windowReference, "innerWidth"); 35 | height = await helper.InvokeAsync("getAttribute", windowReference, "innerHeight"); 36 | } 37 | 38 | public record ClientRect(double x, double y, double width, double height); 39 | 40 | public async void HandleActivated(object? sender, ConfettiOptions options) 41 | { 42 | if (playing) return; 43 | 44 | (double X, double Y)? originPosition = null; 45 | if (options.Origin is { } origin) 46 | { 47 | var helper = await JSRuntime.GetHelperAsync(); 48 | var jSInstance = await helper.InvokeAsync("getJSReference", origin); 49 | var client = await jSInstance.InvokeAsync("getBoundingClientRect"); 50 | originPosition = (X: client.x + client.width / 2, Y: client.y + client.height / 2); 51 | } 52 | 53 | confettiPieces = Enumerable 54 | .Range(0, options.Pieces) 55 | .Select(i => 56 | new ConfettiPiece( 57 | options.Colors[Random.Shared.Next(options.Colors.Length)], 58 | options.Milliseconds + (int)((Random.Shared.NextDouble() * 2 - 1) * options.VariationInMilliseconds), 59 | options.Mode switch 60 | { 61 | ConfettiOriginMode.FromBottomCenter => FromBottomCenterPositions(), 62 | ConfettiOriginMode.FromElement when originPosition is not null => FromElementPositions(originPosition.Value), 63 | _ => FromBottomCenterPositions() 64 | } 65 | ) 66 | ).ToList(); 67 | playing = true; 68 | StateHasChanged(); 69 | await Task.Delay(options.Milliseconds + options.VariationInMilliseconds); 70 | confettiPieces = new(); 71 | playing = false; 72 | StateHasChanged(); 73 | } 74 | 75 | private (double X, double Y)[] FromBottomCenterPositions() 76 | { 77 | var x = Random.Shared.NextDouble() - 0.5; 78 | var y = Random.Shared.NextDouble(); 79 | var end = Random.Shared.NextDouble(); 80 | return [(width / 2, height), (width / 2 + x * width / 3 * 2, height / 2 - y * height / 2), (width / 2 + x * width / 3 * 4, height + end * height / 3)]; 81 | } 82 | 83 | private (double X, double Y)[] FromElementPositions((double x, double y) originPosition) 84 | { 85 | var x = Random.Shared.NextDouble() - 0.5; 86 | var y = Random.Shared.NextDouble(); 87 | var end = Random.Shared.NextDouble(); 88 | return [originPosition, (originPosition.x + x * width / 3 * 2, height / 2 - y * height / 2), (originPosition.x + x * width / 3 * 4, height + end * height / 3)]; 89 | } 90 | 91 | public void Dispose() 92 | { 93 | ConfettiService.Activated -= HandleActivated; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/ConfettiAnimator.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.JSInterop 2 | 3 | 8 | 9 | 10 | @code { 11 | protected ElementReference animateReference { get; set; } 12 | protected SVGAnimationElement? animationElement; 13 | 14 | [Inject] 15 | public required IJSRuntime JSRuntime { get; set; } 16 | 17 | [Parameter, EditorRequired] 18 | public required ConfettiPiece ConfettiPiece { get; set; } 19 | 20 | protected override async Task OnAfterRenderAsync(bool firstRender) 21 | { 22 | if (!firstRender) return; 23 | 24 | animationElement = await SVGAnimationElement.CreateAsync(JSRuntime, animateReference); 25 | 26 | await animationElement.BeginElementAsync(); 27 | await animationElement.EndElementAtAsync(ConfettiPiece.Milliseconds); 28 | } 29 | 30 | private string SmoothPath((double X, double Y)[] points) 31 | { 32 | // Parameter for smoothness of path in interval [0, 0.5] 33 | double smoothness = 1.0 / 3.0; 34 | 35 | var result = ""; 36 | if (points.Length >= 2) 37 | { 38 | result = $"M {points[0].X.AsString()} {points[0].Y.AsString()} "; 39 | for (int i = 1; i < points.Length - 1; i++) 40 | { 41 | result += $"S {(points[i - 1].X * smoothness / 2 + points[i].X - points[i + 1].X * smoothness / 2).AsString()} {(points[i - 1].Y * smoothness / 2 + points[i].Y - points[i + 1].Y * smoothness / 2).AsString()} {points[i].X.AsString()} {points[i].Y.AsString()} "; 42 | } 43 | result += $"S {(points[^2].X * smoothness + points[^1].X * (1 - smoothness)).AsString()} {(points[^2].Y * smoothness + points[^1].Y * (1 - smoothness)).AsString()} {points[^1].X.AsString()} {points[^1].Y.AsString()} "; 44 | } 45 | return result; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/ConfettiOptions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 4 | 5 | public class ConfettiOptions : EventArgs 6 | { 7 | public int Pieces { get; set; } = 300; 8 | 9 | public int Milliseconds { get; set; } = 1000; 10 | 11 | public int VariationInMilliseconds { get; set; } = 200; 12 | 13 | public string[] Colors { get; set; } = ["#F4F", "#44F", "#4F4", "#F44", "#9F0"]; 14 | 15 | public ConfettiOriginMode Mode { get; set; } = ConfettiOriginMode.FromBottomCenter; 16 | 17 | public ElementReference? Origin { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/ConfettiOriginMode.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 2 | 3 | public enum ConfettiOriginMode 4 | { 5 | FromBottomCenter, 6 | FromElement 7 | } 8 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/ConfettiPiece.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 2 | 3 | public record struct ConfettiPiece(string Color, int Milliseconds, (double X, double Y)[] Positions); -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/ConfettiService.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 2 | 3 | public class ConfettiService 4 | { 5 | public event ActivatedEventHandler Activated; 6 | 7 | public void Activate(ConfettiOptions options) 8 | { 9 | Activated?.Invoke(this, options); 10 | } 11 | 12 | public delegate void ActivatedEventHandler(Object sender, ConfettiOptions e); 13 | } 14 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/DoubleExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 4 | 5 | public static class DoubleExtensions 6 | { 7 | public static string AsString(this double d) => d.ToString(CultureInfo.InvariantCulture); 8 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Confetti/IServiceExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 2 | 3 | public static class IServiceExtensions 4 | { 5 | public static IServiceCollection AddConfettiService(this IServiceCollection serviceCollection) 6 | { 7 | return serviceCollection.AddScoped(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/CustomRenderModes.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Web; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.WebAppSample; 4 | public static class CustomRenderModes 5 | { 6 | public static readonly InteractiveServerRenderMode InteractiveServerRenderModeNoPreRender 7 | = new InteractiveServerRenderMode(prerender: false); 8 | } -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/KristofferStrube.Blazor.SVGAnimation.WebAppSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Program.cs: -------------------------------------------------------------------------------- 1 | using KristofferStrube.Blazor.SVGAnimation.WebAppSample.Components; 2 | using KristofferStrube.Blazor.SVGAnimation.WebAppSample.Confetti; 3 | using Microsoft.AspNetCore.Components.Web; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | builder.Services 9 | .AddConfettiService() 10 | .AddRazorComponents() 11 | .AddInteractiveServerComponents(); 12 | 13 | var app = builder.Build(); 14 | 15 | // Configure the HTTP request pipeline. 16 | if (!app.Environment.IsDevelopment()) 17 | { 18 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 19 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 20 | app.UseHsts(); 21 | } 22 | 23 | app.UseHttpsRedirection(); 24 | 25 | app.UseStaticFiles(); 26 | app.UseAntiforgery(); 27 | 28 | app.MapRazorComponents() 29 | .AddInteractiveServerRenderMode(); 30 | 31 | app.Run(); 32 | 33 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:41357", 8 | "sslPort": 44353 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5255", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7052;http://localhost:5255", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/wwwroot/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | a, .btn-link { 6 | color: #006bb7; 7 | } 8 | 9 | .btn-primary { 10 | color: #fff; 11 | background-color: #1b6ec2; 12 | border-color: #1861ac; 13 | } 14 | 15 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 16 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 17 | } 18 | 19 | .content { 20 | padding-top: 1.1rem; 21 | } 22 | 23 | h1:focus { 24 | outline: none; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid #e50000; 33 | } 34 | 35 | .validation-message { 36 | color: #e50000; 37 | } 38 | 39 | .blazor-error-boundary { 40 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 41 | padding: 1rem 1rem 1rem 3.7rem; 42 | color: white; 43 | } 44 | 45 | .blazor-error-boundary::after { 46 | content: "An error has occurred." 47 | } 48 | 49 | .darker-border-checkbox.form-check-input { 50 | border-color: #929292; 51 | } 52 | -------------------------------------------------------------------------------- /samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KristofferStrube/Blazor.SVGAnimation/e39f7386e0b5bf7e7c98ef0441c181dc8c812d5f/samples/KristofferStrube.Blazor.SVGAnimation.WebAppSample/wwwroot/favicon.png -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/Extensions/IJSRuntimeExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation.Extensions; 4 | 5 | internal static class IJSRuntimeExtensions 6 | { 7 | private const string scriptUrl = "./_content/KristofferStrube.Blazor.SVGAnimation/KristofferStrube.Blazor.SVGAnimation.js"; 8 | 9 | internal static async Task GetHelperAsync(this IJSRuntime jSRuntime) 10 | { 11 | return await jSRuntime.InvokeAsync( 12 | "import", scriptUrl); 13 | } 14 | internal static async Task GetInProcessHelperAsync(this IJSRuntime jSRuntime) 15 | { 16 | return await jSRuntime.InvokeAsync( 17 | "import", scriptUrl); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/Extensions/IServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.JSInterop; 3 | 4 | namespace KristofferStrube.Blazor.SVGAnimation; 5 | 6 | public static class IServiceCollectionExtensions 7 | { 8 | [Obsolete("This doesn't follow the pattern for creation of wrapper object that we wish to continue with so it will be removed in the next major release. Use one of the static SVGAnimationElement.CreateAsync methods instead.")] 9 | public static IServiceCollection AddSVGAnimationService(this IServiceCollection services) 10 | { 11 | return services.AddScoped(sp => new SVGAnimationService(sp.GetRequiredService())); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/ISVGAnimationService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace KristofferStrube.Blazor.SVGAnimation 4 | { 5 | public interface ISVGAnimationService 6 | { 7 | ValueTask DisposeAsync(); 8 | 9 | [Obsolete("This doesn't follow the pattern for creation of wrapper object that we wish to continue with so it will be removed in the next major release. Use one of the static SVGAnimationElement.CreateAsync methods instead.")] 10 | ValueTask GreateSVGAnimationElement(ElementReference elementReference); 11 | } 12 | } -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/KristofferStrube.Blazor.SVGAnimation.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | SVG Animation API wrapper 8 | SVG Animation API wrapper implementation for Blazor. 9 | KristofferStrube.Blazor.SVGAnimation 10 | Blazor;Wasm;Wrapper;SVG;Animation;SVGAnimation;JSInterop 11 | https://github.com/KristofferStrube/Blazor.SVGAnimation 12 | git 13 | MIT 14 | 0.2.0 15 | Kristoffer Strube 16 | README.md 17 | icon.png 18 | 19 | 20 | 21 | 22 | True 23 | \ 24 | 25 | 26 | True 27 | \ 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/SVGAnimationElement.InProcess.cs: -------------------------------------------------------------------------------- 1 | using KristofferStrube.Blazor.DOM; 2 | using KristofferStrube.Blazor.DOM.Extensions; 3 | using KristofferStrube.Blazor.WebIDL; 4 | using Microsoft.AspNetCore.Components; 5 | using Microsoft.JSInterop; 6 | 7 | namespace KristofferStrube.Blazor.SVGAnimation; 8 | 9 | public class SVGAnimationElementInProcess : SVGAnimationElement, IEventTargetInProcess 10 | { 11 | protected readonly IJSInProcessObjectReference domInProcessHelper; 12 | protected readonly IJSInProcessObjectReference inProcessHelper; 13 | 14 | public new IJSInProcessObjectReference JSReference { get; set; } 15 | 16 | public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) 17 | { 18 | IJSInProcessObjectReference domInProcessHelper = await DOM.Extensions.IJSRuntimeExtensions.GetInProcessHelperAsync(jSRuntime); 19 | IJSInProcessObjectReference inProcessHelper = await Extensions.IJSRuntimeExtensions.GetInProcessHelperAsync(jSRuntime); 20 | return new SVGAnimationElementInProcess(jSRuntime, domInProcessHelper, inProcessHelper, jSReference); 21 | } 22 | 23 | public static new async Task CreateAsync(IJSRuntime jSRuntime, ElementReference elementReference) 24 | { 25 | IJSInProcessObjectReference domInProcessHelper = await DOM.Extensions.IJSRuntimeExtensions.GetInProcessHelperAsync(jSRuntime); 26 | IJSInProcessObjectReference inProcessHelper = await Extensions.IJSRuntimeExtensions.GetInProcessHelperAsync(jSRuntime); 27 | IJSInProcessObjectReference jSInstance = await inProcessHelper.InvokeAsync("getJSReference", elementReference); 28 | return new SVGAnimationElementInProcess(jSRuntime, domInProcessHelper, inProcessHelper, jSInstance); 29 | } 30 | 31 | protected SVGAnimationElementInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference domInProcessHelper, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference) : base(jSRuntime, jSReference) 32 | { 33 | this.domInProcessHelper = domInProcessHelper; 34 | this.inProcessHelper = inProcessHelper; 35 | JSReference = jSReference; 36 | } 37 | 38 | public new IJSObjectReference TargetElement => inProcessHelper.Invoke("getAttribute", JSReference, "targetElement"); 39 | 40 | /// 41 | public void AddEventListener(string type, EventListenerInProcess? callback, AddEventListenerOptions? options = null) 42 | where TEvent : Event, IJSCreatable where TInProcessEvent : IJSInProcessCreatable 43 | { 44 | this.AddEventListener(domInProcessHelper, type, callback, options); 45 | } 46 | 47 | /// 48 | public void AddEventListener(EventListenerInProcess? callback, AddEventListenerOptions? options = null) 49 | where TEvent : Event, IJSCreatable where TInProcessEvent : IJSInProcessCreatable 50 | { 51 | this.AddEventListener(domInProcessHelper, callback, options); 52 | } 53 | 54 | /// 55 | public void RemoveEventListener(string type, EventListenerInProcess? callback, EventListenerOptions? options = null) 56 | where TEvent : Event, IJSCreatable where TInProcessEvent : IJSInProcessCreatable 57 | { 58 | this.RemoveEventListener(domInProcessHelper, type, callback, options); 59 | } 60 | 61 | /// 62 | public void RemoveEventListener(EventListenerInProcess? callback, EventListenerOptions? options = null) 63 | where TEvent : Event, IJSCreatable where TInProcessEvent : IJSInProcessCreatable 64 | { 65 | this.RemoveEventListener(domInProcessHelper, callback, options); 66 | } 67 | 68 | public bool DispatchEvent(Event eventInstance) 69 | { 70 | return IEventTargetInProcessExtensions.DispatchEvent(this, eventInstance); 71 | } 72 | 73 | public async Task> AddOnBeginEventListenerAsync(Action callback, AddEventListenerOptions? options = null) 74 | { 75 | EventListenerInProcess eventListener = await EventListenerInProcess.CreateAsync(JSRuntime, callback); 76 | AddEventListener("beginEvent", eventListener, options); 77 | return eventListener; 78 | } 79 | 80 | public void RemoveOnBeginEventListener(EventListenerInProcess callback, EventListenerOptions? options = null) 81 | { 82 | RemoveEventListener("beginEvent", callback, options); 83 | } 84 | 85 | public async Task> AddOnEndEventListenerAsync(Action callback, AddEventListenerOptions? options = null) 86 | { 87 | EventListenerInProcess eventListener = await EventListenerInProcess.CreateAsync(JSRuntime, callback); 88 | AddEventListener("endEvent", eventListener, options); 89 | return eventListener; 90 | } 91 | 92 | public void RemoveOnEndEventListener(EventListenerInProcess callback, EventListenerOptions? options = null) 93 | { 94 | RemoveEventListener("endEvent", callback, options); 95 | } 96 | 97 | public async Task> AddOnRepeatEventListenerAsync(Action callback, AddEventListenerOptions? options = null) 98 | { 99 | EventListenerInProcess eventListener = await EventListenerInProcess.CreateAsync(JSRuntime, callback); 100 | AddEventListener("repeatEvent", eventListener, options); 101 | return eventListener; 102 | } 103 | 104 | public void RemoveOnRepeatEventListener(EventListenerInProcess callback, EventListenerOptions? options = null) 105 | { 106 | RemoveEventListener("repeatEvent", callback, options); 107 | } 108 | 109 | public float GetStartTime() 110 | { 111 | return JSReference.Invoke("getStartTime"); 112 | } 113 | 114 | public float GetCurrentTime() 115 | { 116 | return JSReference.Invoke("getCurrentTime"); 117 | } 118 | 119 | public float GetSimpleDuration() 120 | { 121 | return JSReference.Invoke("getSimpleDuration"); 122 | } 123 | 124 | public void BeginElement() 125 | { 126 | JSReference.InvokeVoid("beginElement"); 127 | } 128 | 129 | public void BeginElementAt(float offset) 130 | { 131 | JSReference.InvokeVoid("beginElementAt", offset); 132 | } 133 | 134 | public void EndElement() 135 | { 136 | JSReference.InvokeVoid("endElement"); 137 | } 138 | 139 | public void EndElementAt(float offset) 140 | { 141 | JSReference.InvokeVoid("endElementAt", offset); 142 | } 143 | 144 | public new async ValueTask DisposeAsync() 145 | { 146 | await base.DisposeAsync(); 147 | await domInProcessHelper.DisposeAsync(); 148 | await inProcessHelper.DisposeAsync(); 149 | GC.SuppressFinalize(this); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/SVGAnimationElement.cs: -------------------------------------------------------------------------------- 1 | using KristofferStrube.Blazor.DOM; 2 | using KristofferStrube.Blazor.SVGAnimation.Extensions; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.JSInterop; 5 | 6 | namespace KristofferStrube.Blazor.SVGAnimation; 7 | 8 | /// 9 | /// SVGAnimationElement browser specs 10 | /// 11 | public class SVGAnimationElement : EventTarget 12 | { 13 | // Old Obsolete fields. 14 | protected readonly IJSInProcessObjectReference helper; 15 | 16 | // New fields that will be the only ones used after the next major version 17 | protected readonly Lazy> svgAnimationHelperTask; 18 | 19 | public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) 20 | { 21 | return Task.FromResult(new(jSRuntime, jSReference)); 22 | } 23 | 24 | public static new async Task CreateAsync(IJSRuntime jSRuntime, ElementReference elementReference) 25 | { 26 | IJSObjectReference helper = await jSRuntime.GetHelperAsync(); 27 | IJSObjectReference jSInstance = await helper.InvokeAsync("getJSReference", elementReference); 28 | return new(jSRuntime, jSInstance); 29 | } 30 | 31 | [Obsolete("This is not compatible with Blazor WASM so it will be removed in the next major version. Either use the SVGAnimationElement(IJSRuntime jSRuntime, IJSObjectReference jSReference) constructor instead.")] 32 | internal SVGAnimationElement(IJSRuntime jSRuntime, IJSObjectReference jSReference, IJSInProcessObjectReference helper) : this(jSRuntime, jSReference) 33 | { 34 | this.helper = helper; 35 | } 36 | 37 | #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. This will be removed once we move await from the IJSInProcessObjectReference in next major release. 38 | protected SVGAnimationElement(IJSRuntime jSRuntime, IJSObjectReference jSReference) : base(jSRuntime, jSReference) 39 | #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 40 | { 41 | svgAnimationHelperTask = new(jSRuntime.GetHelperAsync); 42 | } 43 | 44 | [Obsolete("This is not compatible with Blazor WASM so it will be removed in the next major version. Either use the SVGAnimationElementInProcess variant or use the GetTargetElementAsync method instead.")] 45 | public IJSObjectReference TargetElement => helper.Invoke("getAttribute", JSReference, "targetElement"); 46 | 47 | public async Task GetTargetElementAsync() 48 | { 49 | return await helper.InvokeAsync("getAttribute", JSReference, "targetElement"); 50 | } 51 | 52 | public async Task> AddOnBeginEventListenerAsync(Func callback, AddEventListenerOptions? options = null) 53 | { 54 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, callback); 55 | await AddEventListenerAsync("beginEvent", eventListener, options); 56 | return eventListener; 57 | } 58 | 59 | public async Task RemoveOnBeginEventListenerAsync(EventListener callback, EventListenerOptions? options = null) 60 | { 61 | await RemoveEventListenerAsync("beginEvent", callback, options); 62 | } 63 | 64 | [Obsolete("This used an old way to make events where you could not unsubscribe so it will be removed in the next major version. Use AddOnBeginEventListener instead.")] 65 | public async ValueTask SubscribeToBeginAsync(Action action) 66 | { 67 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, (Event e) => { action(); return Task.CompletedTask; }); 68 | await AddEventListenerAsync("beginEvent", eventListener); 69 | } 70 | 71 | public async Task> AddOnEndEventListenerAsync(Func callback, AddEventListenerOptions? options = null) 72 | { 73 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, callback); 74 | await AddEventListenerAsync("endEvent", eventListener, options); 75 | return eventListener; 76 | } 77 | 78 | public async Task RemoveOnEndEventListenerAsync(EventListener callback, EventListenerOptions? options = null) 79 | { 80 | await RemoveEventListenerAsync("endEvent", callback, options); 81 | } 82 | 83 | [Obsolete("This used an old way to make events where you could not unsubscribe so it will be removed in the next major version. Use AddOnEndEventListener instead.")] 84 | public async ValueTask SubscribeToEndAsync(Action action) 85 | { 86 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, (Event e) => { action(); return Task.CompletedTask; }); 87 | await AddEventListenerAsync("endEvent", eventListener); 88 | } 89 | 90 | public async Task> AddOnRepeatEventListenerAsync(Func callback, AddEventListenerOptions? options = null) 91 | { 92 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, callback); 93 | await AddEventListenerAsync("repeatEvent", eventListener, options); 94 | return eventListener; 95 | } 96 | 97 | public async Task RemoveOnRepeatEventListenerAsync(EventListener callback, EventListenerOptions? options = null) 98 | { 99 | await RemoveEventListenerAsync("repeatEvent", callback, options); 100 | } 101 | 102 | [Obsolete("This used an old way to make events where you could not unsubscribe so it will be removed in the next major version. Use AddOnRepeatEventListener instead.")] 103 | public async ValueTask SubscribeToRepeatAsync(Action action) 104 | { 105 | EventListener eventListener = await EventListener.CreateAsync(JSRuntime, (Event e) => { action(); return Task.CompletedTask; }); 106 | await AddEventListenerAsync("repeatEvent", eventListener); 107 | } 108 | 109 | public async ValueTask GetStartTimeAsync() 110 | { 111 | return await JSReference.InvokeAsync("getStartTime"); 112 | } 113 | 114 | public async ValueTask GetCurrentTimeAsync() 115 | { 116 | return await JSReference.InvokeAsync("getCurrentTime"); 117 | } 118 | 119 | public async ValueTask GetSimpleDurationAsync() 120 | { 121 | return await JSReference.InvokeAsync("getSimpleDuration"); 122 | } 123 | 124 | public async ValueTask BeginElementAsync() 125 | { 126 | await JSReference.InvokeVoidAsync("beginElement"); 127 | } 128 | 129 | public async ValueTask BeginElementAtAsync(float offset) 130 | { 131 | await JSReference.InvokeVoidAsync("beginElementAt", offset); 132 | } 133 | 134 | public async ValueTask EndElementAsync() 135 | { 136 | await JSReference.InvokeVoidAsync("endElement"); 137 | } 138 | 139 | public async ValueTask EndElementAtAsync(float offset) 140 | { 141 | await JSReference.InvokeVoidAsync("endElementAt", offset); 142 | } 143 | 144 | public new async ValueTask DisposeAsync() 145 | { 146 | await base.DisposeAsync(); 147 | if (svgAnimationHelperTask.IsValueCreated) 148 | { 149 | IJSObjectReference module = await svgAnimationHelperTask.Value; 150 | await module.DisposeAsync(); 151 | } 152 | GC.SuppressFinalize(this); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/SVGAnimationService.cs: -------------------------------------------------------------------------------- 1 | using KristofferStrube.Blazor.SVGAnimation.Extensions; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.JSInterop; 4 | 5 | namespace KristofferStrube.Blazor.SVGAnimation; 6 | 7 | public class SVGAnimationService : IAsyncDisposable, ISVGAnimationService 8 | { 9 | protected readonly IJSRuntime jSRuntime; 10 | private readonly Lazy> helperTask; 11 | 12 | [Obsolete("This doesn't follow the pattern for creation of wrapper object that we wish to continue with so it will be removed in the next major release. Use one of the static SVGAnimationElement.CreateAsync methods instead.")] 13 | public SVGAnimationService(IJSRuntime jsRuntime) 14 | { 15 | this.jSRuntime = jsRuntime; 16 | helperTask = new(jSRuntime.GetInProcessHelperAsync); 17 | } 18 | 19 | [Obsolete("This doesn't follow the pattern for creation of wrapper object that we wish to continue with so it will be removed in the next major release. Use one of the static SVGAnimationElement.CreateAsync methods instead.")] 20 | public async ValueTask GreateSVGAnimationElement(ElementReference elementReference) 21 | { 22 | IJSInProcessObjectReference helper = await helperTask.Value; 23 | IJSObjectReference jsReference = await helper.InvokeAsync("getJSReference", elementReference); 24 | return new SVGAnimationElement(jSRuntime, jsReference, helper); 25 | } 26 | 27 | public async ValueTask DisposeAsync() 28 | { 29 | if (helperTask.IsValueCreated) 30 | { 31 | IJSInProcessObjectReference module = await helperTask.Value; 32 | await module.DisposeAsync(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/KristofferStrube.Blazor.SVGAnimation/wwwroot/KristofferStrube.Blazor.SVGAnimation.js: -------------------------------------------------------------------------------- 1 | export function getAttribute(object, attribute) { return object[attribute]; } 2 | 3 | export function getJSReference(element) { return element; } --------------------------------------------------------------------------------