New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

canvas-area

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-area

lightweight html container element as a controller parent for one or more canvas elements. It allows zoom, pan and resize interactions

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by62.5%
Maintainers
1
Weekly downloads
 
Created
Source

canvas-area

What is it ... ?

canvas-area is a lightweight custom html element as a controller parent for one or more canvas elements. It allows zoom, pan and resize interactions.

Show me ...

show

Where is the markup code ...

<canvas-area id="ca" width="401" height="301" resizable="both">
    <canvas id="c"></canvas>
</canvas-area>

Attributes

  • width: width of element in px.
  • height: height of element in px.
  • resizable: one of ['none', 'horizontal', 'vertical', 'both'].
  • cartesian: true or false

Example please ...

Show me the scripting API ...

canvas-area behaves as a standard html container element with known inherited DOM properties and methods. Additionally it offers properties ...

PropertyTypeValueDefault
widthNumberwidth of element in px300 px
heightNumberheight of element in px150 px
resizableStringone of ['none', 'horizontal', 'vertical', 'both']'none'
cursorStringsimple interface to CSS cursor attribute.'auto'
view{x,y,scl}origin location x,y in px and scaling factor scl{0,0,1}
cartesianBooleantrue: y-axis pointing up,
false: y-axis pointing down
false

... methods ...

MethodArgumentsReturnsComment
pan({dx,dy})dx: delta x
dy: delta y
undefinedorigin displacement. Modifies view property
zoom({x,y,scl})x: x-center
y: y-center
scl: factor
undefinedzoom about point {x,y} by factor scl. Modifies view property
pntToUsr({x,y})pointpointtransform argument point (device coordinates) to result point (user coordinates) with respect to view property
notify(key,value)key: event type
value: event data
undefinednotify observers of event type key about event value
observe(key,handler)key: event type
handler: event handler
undefinedlet handler get invoked with event type key.

... and events, which can be observed via observe method.

TypeObjectValue
'pointer'{x,y,...}*User has moved the pointer.
'drag'{x,y,...}*User has moved the pointer with left button down.
'resize'{width,height}User did resize canvas-area element
'view'{x,y,scl}User modified the view property via pan, zoom, ...
'buttondown'{x,y,...}*User has pressed the pointer device's button down.
'buttonup'{x,y,...}*User has released the pointer device's button.
'pointerenter'{x,y,...}*pointer has entered the canvas-area.
'pointerleave'{x,y,...}*pointer has left the canvas-area.

{x,y,...}* custom event data object:

PropertyDescription
x,yPointer location in device coordinates.
dx,dyPointer displacement in device coordinates since last pointer event.
buttonsDevice buttons pressed (1:left, 2: right, 4: middle button).
deltaMouse wheel delta units.

CDN

Use following links for texmath.js and texmath.css

  • https://gitcdn.xyz/cdn/goessner/canvas-area/master/canvas-area.js

Changelog

License

canvas-area is licensed under the MIT License

© Stefan Gössner

Keywords

FAQs

Package last updated on 06 Jan 2018

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