Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pwabuilder/pwa-inking

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pwabuilder/pwa-inking

`pwa-inking` is a [web component](https://meowni.ca/posts/web-components-with-otters/) from the [PWABuilder](https://pwabuilder.com) team that allows you to quickly add a 2D inking canvas (with an optional toolbar) to your Progressive Web App!

  • 0.5.5
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

pwa-inking

pwa-inking is a web component from the PWABuilder team that allows you to quickly add a 2D inking canvas (with an optional toolbar) to your Progressive Web App!

Built with lit-element

What does it look like?

An image of what the component looks like

Supported Browsers

  • Edge
  • Chrome
  • More coming soon!

Using this component

Install

There are two ways to use this component. For simple projects or just to get started fast, we recommend using the component by script tag. If your project is using npm then we recommend using the npm package.

Script tag

  • Put this script tag in the head of your index.html:
<script
  type="module"
  src="https://cdn.jsdelivr.net/npm/@pwabuilder/pwa-inking"
></script>

NPM

  • Run npm install @pwabuilder/pwa-inking
  • import with import '@pwabuilder/pwa-inking'

Adding the component to your code

You can use the element <inking-canvas></inking-canvas> anywhere in your template, JSX, html etc. By itself, you will get a blank, bordered canvas which you can control through its APIs (see table for details).

You can also add the <inking-toolbar></inking-toolbar> element beneath the <inking-canvas></inking-canvas> element so the user can control the canvas visually. To connect these elements, their respective canvas and name attribute values must match.

By default <inking-canvas></inking-canvas> will create ink strokes with a width depending on the active pointer event:

Pointer EventProperty influencing ink stroke widthNotes
mousewidthAlways 1 pixel
touchwidthChanges with surface area of inking screen pressed
penpressureChanges with downward force applied to inking screen

For now, the stroke width regardless of pointer event type can be set and fixed through the <inking-toolbar></inking-toolbar>.

Check out a live demo of pwa-inking!

APIs

inking-canvas

Properties

PropertyAttributeDescriptionTypeDefault
namenameUsed to connect an inking toolbarstring""
canvasHeightheightFills parent by defaultnumber-1
canvasWidthwidthFills parent by defaultnumber-1

Methods

nameDescription
changeUtensilColor(color: string)Changes ink color
changeStrokeSize(strokeSize: number)Changes ink stroke width
changeToolStyle(toolStyle: string)Changes active canvas tool
eraseAll()Deletes all canvas ink
getScale()Returns canvas size relative to its content's aspect ratio

inking-toolbar

Properties

PropertyAttributeDescriptionTypeDefault
orientationorientationToolbar layout directionstringhorizontal
targetInkingCanvascanvasConnects to canvas whose name matches its valuestring""

Methods

None

FAQs

Package last updated on 14 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc