dom

package
Version: v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LeftMouseButton = MouseButton(iota)
	MiddleMouseButton
	RightMouseButton
)

Variables

View Source
var Win = &Window{Object: js.Global.Get("window")}

Win is the global window.

Functions

This section is empty.

Types

type A

type A struct{ *Element }

A represents an HTML <A> element.

func NewA

func NewA() *A

NewA returns a new A element.

func (A) AppendNode

func (n A) AppendNode(child Node)

func (A) Children

func (n A) Children() []Node

type Button

type Button struct{ *Element }

Button represents an HTML <button> element.

func NewButton

func NewButton() *Button

NewButton returns a new Button element.

func (Button) AppendNode

func (n Button) AppendNode(child Node)

func (Button) Children

func (n Button) Children() []Node

type CSSStyleDeclaration

type CSSStyleDeclaration struct {
	*js.Object
	AlignContent              string        `js:"alignContent"`
	AlignItems                string        `js:"alignItems"`
	AlignSelf                 string        `js:"AlignSelf"`
	AlignmentBaseline         string        `js:"alignmentBaseline"`
	All                       string        `js:"all"`
	Animation                 string        `js:"animation"`
	AnimationDelay            string        `js:"animationDelay"`
	AnimationDirection        string        `js:"animationDirection"`
	AnimationDuration         string        `js:"animationDuration"`
	AnimationFillMode         string        `js:"animationFillMode"`
	AnimationIterationCount   string        `js:"animationIterationCount"`
	AnimationName             string        `js:"animationName"`
	AnimationPlayState        string        `js:"animationPlayState"`
	AnimationTimingFunction   string        `js:"animationTimingFunction"`
	BackfaceVisibility        string        `js:"backfaceVisibility"`
	Background                string        `js:"background"`
	BackgroundAttachment      string        `js:"backgroundAttachment"`
	BackgroundBlendMode       string        `js:"backgroundBlendMode"`
	BackgroundClip            string        `js:"backgroundClip"`
	BackgroundColor           Color         `js:"backgroundColor"`
	BackgroundImage           string        `js:"backgroundImage"`
	BackgroundOrigin          string        `js:"backgroundOrigin"`
	BackgroundPosition        string        `js:"backgroundPosition"`
	BackgroundPositionX       string        `js:"backgroundPositionX"`
	BackgroundPositionY       string        `js:"backgroundPositionY"`
	BackgroundRepeat          string        `js:"backgroundRepeat"`
	BackgroundRepeatX         string        `js:"backgroundRepeatX"`
	BackgroundRepeatY         string        `js:"backgroundRepeatY"`
	BackgroundSize            string        `js:"backgroundSize"`
	BaselineShift             string        `js:"baselineShift"`
	Border                    string        `js:"border"`
	BorderBottom              string        `js:"borderBottom"`
	BorderBottomColor         Color         `js:"borderBottomColor"`
	BorderBottomLeftRadius    string        `js:"borderBottomLeftRadius"`
	BorderBottomRightRadius   string        `js:"borderBottomRightRadius"`
	BorderBottomStyle         string        `js:"borderBottomStyle"`
	BorderBottomWidth         string        `js:"borderBottomWidth"`
	BorderCollapse            string        `js:"borderCollapse"`
	BorderColor               Color         `js:"borderColor"`
	BorderImage               string        `js:"borderImage"`
	BorderImageOutset         string        `js:"borderImageOutset"`
	BorderImageRepeat         string        `js:"borderImageRepeat"`
	BorderImageSlice          string        `js:"borderImageSlice"`
	BorderImageSource         string        `js:"borderImageSource"`
	BorderImageWidth          string        `js:"borderImageWidth"`
	BorderLeft                string        `js:"borderLeft"`
	BorderLeftColor           Color         `js:"borderLeftColor"`
	BorderLeftStyle           string        `js:"borderLeftStyle"`
	BorderLeftWidth           string        `js:"borderLeftWidth"`
	BorderRadius              string        `js:"borderRadius"`
	BorderRight               string        `js:"borderRight"`
	BorderRightColor          Color         `js:"borderRightColor"`
	BorderRightStyle          string        `js:"borderRightStyle"`
	BorderRightWidth          string        `js:"borderRightWidth"`
	BorderSpacing             string        `js:"borderSpacing"`
	BorderStyle               string        `js:"borderStyle"`
	BorderTop                 string        `js:"borderTop"`
	BorderTopColor            Color         `js:"borderTopColor"`
	BorderTopLeftRadius       string        `js:"borderTopLeftRadius"`
	BorderTopRightRadius      string        `js:"borderTopRightRadius"`
	BorderTopStyle            string        `js:"borderTopStyle"`
	BorderTopWidth            string        `js:"borderTopWidth"`
	BorderWidth               string        `js:"borderWidth"`
	Bottom                    string        `js:"bottom"`
	BoxShadow                 string        `js:"boxShadow"`
	BoxSizing                 string        `js:"boxSizing"`
	BreakAfter                string        `js:"breakAfter"`
	BreakBefore               string        `js:"breakBefore"`
	BreakInside               string        `js:"breakInside"`
	BufferedRendering         string        `js:"bufferedRendering"`
	CaptionSide               string        `js:"captionSide"`
	Clear                     string        `js:"clear"`
	Clip                      string        `js:"clip"`
	ClipPath                  string        `js:"clipPath"`
	ClipRule                  string        `js:"clipRule"`
	Color                     Color         `js:"color"`
	ColorInterpolation        string        `js:"colorInterpolation"`
	ColorInterpolationFilters string        `js:"colorInterpolationFilters"`
	ColorRendering            string        `js:"colorRendering"`
	ColumnCount               string        `js:"columnCount"`
	ColumnFill                string        `js:"columnFill"`
	ColumnGap                 string        `js:"columnGap"`
	ColumnRule                string        `js:"columnRule"`
	ColumnRuleColor           Color         `js:"columnRuleColor"`
	ColumnRuleStyle           string        `js:"columnRuleStyle"`
	ColumnRuleWidth           string        `js:"columnRuleWidth"`
	ColumnSpan                string        `js:"columnSpan"`
	ColumnWidth               string        `js:"columnWidth"`
	Columns                   string        `js:"columns"`
	Content                   string        `js:"content"`
	CounterIncrement          string        `js:"counterIncrement"`
	CounterReset              string        `js:"counterReset"`
	CSSFloat                  string        `js:"cssFloat"`
	CSSText                   string        `js:"cssText"`
	Cursor                    string        `js:"cursor"`
	Cx                        string        `js:"cx"`
	Cy                        string        `js:"cy"`
	Direction                 string        `js:"direction"`
	Display                   Display       `js:"display"`
	DominantBaseline          string        `js:"dominantBaseline"`
	EmptyCells                string        `js:"emptyCells"`
	Fill                      string        `js:"fill"`
	FillOpacity               string        `js:"fillOpacity"`
	FillRule                  string        `js:"fillRule"`
	Filter                    string        `js:"filter"`
	Flex                      string        `js:"flex"`
	FlexBasis                 string        `js:"flexBasis"`
	FlexDirection             FlexDirection `js:"flexDirection"`
	FlexFlow                  string        `js:"flexFlow"`
	FlexGrow                  string        `js:"flexGrow"`
	FlexShrink                string        `js:"flexShrink"`
	FlexWrap                  string        `js:"flexWrap"`
	Float                     string        `js:"float"`
	FloodColor                string        `js:"floodColor"`
	FloodOpacity              string        `js:"floodOpacity"`
	Font                      string        `js:"font"`
	FontFamily                string        `js:"fontFamily"`
	FontFeatureSettings       string        `js:"fontFeatureSettings"`
	FontKerning               string        `js:"fontKerning"`
	FontSize                  string        `js:"fontSize"`
	FontStretch               string        `js:"fontStretch"`
	FontStyle                 string        `js:"fontStyle"`
	FontVariant               string        `js:"fontVariant"`
	FontVariantLigatures      string        `js:"fontVariantLigatures"`
	FontWeight                string        `js:"fontWeight"`
	Height                    int           `js:"height"`
	ImageRendering            string        `js:"imageRendering"`
	Isolation                 string        `js:"isolation"`
	JustifyContent            string        `js:"justifyContent"`
	Left                      string        `js:"left"`
	Length                    string        `js:"length int"`
	LetterSpacing             string        `js:"letterSpacing"`
	LightingColor             Color         `js:"lightingColor"`
	LineHeight                string        `js:"lineHeight"`
	ListStyle                 string        `js:"listStyle"`
	ListStyleImage            string        `js:"listStyleImage"`
	ListStylePosition         string        `js:"listStylePosition"`
	ListStyleType             string        `js:"listStyleType"`
	Margin                    string        `js:"margin"`
	MarginBottom              string        `js:"marginBottom"`
	MarginLeft                string        `js:"marginLeft"`
	MarginRight               string        `js:"marginRight"`
	MarginTop                 string        `js:"marginTop"`
	Marker                    string        `js:"marker"`
	MarkerEnd                 string        `js:"markerEnd"`
	MarkerMid                 string        `js:"markerMid"`
	MarkerStart               string        `js:"markerStart"`
	Mask                      string        `js:"mask"`
	MaskType                  string        `js:"maskType"`
	MaxHeight                 int           `js:"maxHeight"`
	MaxWidth                  int           `js:"maxWidth"`
	MaxZoom                   string        `js:"maxZoom"`
	MinHeight                 int           `js:"minHeight"`
	MinWidth                  int           `js:"minWidth"`
	MinZoom                   string        `js:"minZoom"`
	MixBlendMode              string        `js:"mixBlendMode"`
	Motion                    string        `js:"motion"`
	MotionOffset              string        `js:"motionOffset"`
	MotionPath                string        `js:"motionPath"`
	MotionRotation            string        `js:"motionRotation"`
	ObjectFit                 string        `js:"objectFit"`
	ObjectPosition            string        `js:"objectPosition"`
	Opacity                   string        `js:"opacity"`
	Order                     string        `js:"order"`
	Orientation               string        `js:"orientation"`
	Orphans                   string        `js:"orphans"`
	Outline                   string        `js:"outline"`
	OutlineColor              Color         `js:"outlineColor"`
	OutlineOffset             string        `js:"outlineOffset"`
	OutlineStyle              string        `js:"outlineStyle"`
	OutlineWidth              string        `js:"outlineWidth"`
	Overflow                  string        `js:"overflow"`
	OverflowWrap              string        `js:"overflowWrap"`
	OverflowX                 string        `js:"overflowX"`
	OverflowY                 string        `js:"overflowY"`
	Padding                   string        `js:"padding"`
	PaddingBottom             string        `js:"paddingBottom"`
	PaddingLeft               string        `js:"paddingLeft"`
	PaddingRight              string        `js:"paddingRight"`
	PaddingTop                string        `js:"paddingTop"`
	Page                      string        `js:"page"`
	PageBreakAfter            string        `js:"pageBreakAfter"`
	PageBreakBefore           string        `js:"pageBreakBefore"`
	PageBreakInside           string        `js:"pageBreakInside"`
	PaintOrder                string        `js:"paintOrder"`
	ParentRule                string        `js:"parentRule"`
	Perspective               string        `js:"perspective"`
	PerspectiveOrigin         string        `js:"perspectiveOrigin"`
	PointerEvents             string        `js:"pointerEvents"`
	Position                  Position      `js:"position"`
	Quotes                    string        `js:"quotes"`
	R                         string        `js:"r"`
	Resize                    string        `js:"resize"`
	Right                     string        `js:"right"`
	Rx                        string        `js:"rx"`
	Ry                        string        `js:"ry"`
	ShapeImageThreshold       string        `js:"shapeImageThreshold"`
	ShapeMargin               string        `js:"shapeMargin"`
	ShapeOutside              string        `js:"shapeOutside"`
	ShapeRendering            string        `js:"shapeRendering"`
	Size                      string        `js:"size"`
	Speak                     string        `js:"speak"`
	Src                       string        `js:"src"`
	StopColor                 Color         `js:"stopColor"`
	StopOpacity               string        `js:"stopOpacity"`
	Stroke                    string        `js:"stroke"`
	StrokeDasharray           string        `js:"strokeDasharray"`
	StrokeDashoffset          string        `js:"strokeDashoffset"`
	StrokeLinecap             string        `js:"strokeLinecap"`
	StrokeLinejoin            string        `js:"strokeLinejoin"`
	StrokeMiterlimit          string        `js:"strokeMiterlimit"`
	StrokeOpacity             string        `js:"strokeOpacity"`
	StrokeWidth               string        `js:"strokeWidth"`
	TabSize                   string        `js:"tabSize"`
	TableLayout               string        `js:"tableLayout"`
	TextAlign                 string        `js:"textAlign"`
	TextAlignLast             string        `js:"textAlignLast"`
	TextAnchor                string        `js:"textAnchor"`
	TextCombineUpright        string        `js:"textCombineUpright"`
	TextDecoration            string        `js:"textDecoration"`
	TextIndent                string        `js:"textIndent"`
	TextOrientation           string        `js:"textOrientation"`
	TextOverflow              string        `js:"textOverflow"`
	TextRendering             string        `js:"textRendering"`
	TextShadow                string        `js:"textShadow"`
	TextTransform             string        `js:"textTransform"`
	Top                       string        `js:"top"`
	TouchAction               string        `js:"touchAction"`
	Transform                 string        `js:"transform"`
	TransformOrigin           string        `js:"transformOrigin"`
	TransformStyle            string        `js:"transformStyle"`
	Transition                string        `js:"transition"`
	TransitionDelay           string        `js:"transitionDelay"`
	TransitionDuration        string        `js:"transitionDuration"`
	TransitionProperty        string        `js:"transitionProperty"`
	TransitionTimingFunction  string        `js:"transitionTimingFunction"`
	UnicodeBidi               string        `js:"unicodeBidi"`
	UnicodeRange              string        `js:"unicodeRange"`
	UserZoom                  string        `js:"userZoom"`
	VectorEffect              string        `js:"vectorEffect"`
	VerticalAlign             string        `js:"verticalAlign"`
	Visibility                string        `js:"visibility"`
	WhiteSpace                string        `js:"whiteSpace"`
	Widows                    string        `js:"widows"`
	Width                     int           `js:"width"`
	WillChange                string        `js:"willChange"`
	WordBreak                 string        `js:"wordBreak"`
	WordSpacing               string        `js:"wordSpacing"`
	WordWrap                  string        `js:"wordWrap"`
	WritingMode               string        `js:"writingMode"`
	X                         string        `js:"x"`
	Y                         string        `js:"y"`
	ZIndex                    string        `js:"zIndex"`
	Zoom                      string        `js:"zoom"`
}

type Canvas

type Canvas struct{ *Element }

Canvas represents an HTML <canvas> element.

func NewCanvas

func NewCanvas(width, height int) *Canvas

NewCanvas returns a new Canvas element.

func (Canvas) AppendNode

func (n Canvas) AppendNode(child Node)

func (Canvas) Children

func (n Canvas) Children() []Node

func (*Canvas) Context2D

func (c *Canvas) Context2D() *Context2D

Context2D returns the Context2D for the context.

func (*Canvas) Resize

func (c *Canvas) Resize(width, height int)

Resize sets the size of the canvas.

type CanvasGradient

type CanvasGradient struct{ *js.Object }

type CanvasImageSource

type CanvasImageSource interface{}

CanvasImageSource is any of the following types: HTMLImageElement, HTMLVideoElement, HTMLCanvasElement, or ImageBitmap.

type CanvasPattern

type CanvasPattern struct{ *js.Object }

type Color

type Color string

Color is a CSS color.

const (
	White       Color = "white"
	Black       Color = "black"
	Transparent Color = "transparent"
	Red         Color = "red"
	Green       Color = "green"
	Blue        Color = "blue"
	Yellow      Color = "yellow"
)

func RGB

func RGB(r, g, b float64) Color

RGB returns a new Color with the specified red, green and blue values that each range from 0 to 1.

func RGBA

func RGBA(r, g, b, a float64) Color

RGBA returns a new Color with the specified red, green, blue and alpha values that each range from 0 to 1.

type CompositeOperation

type CompositeOperation string

CompositeOperation is an enumerator of alpha blending composite functions.

type Context2D

type Context2D struct {
	*js.Object

	// LineWidth is the width of lines.
	LineWidth float64 `js:"lineWidth"`

	// LineCap specifies the style of endings on the end of lines.
	LineCap LineCap `js:"lineCap"`

	// LineJoin specifies the type of corners where two lines meet.
	LineJoin LineJoin `js:"lineJoin"`

	// MiterLimit is the miter limit ratio.
	MiterLimit float64 `js:"miterLimit"`

	// LineDashOffset specifies where to start a dash array on a line.
	LineDashOffset float64 `js:"lineDashOffset"`

	// Font is the current font to use for text drawing.
	Font Font `js:"font"`

	// TextAlign specifies text alignment when drawing text.
	TextAlign TextAlign `js:"textAlign"`

	// TextBaseline specifies the text baseline when drawing text.
	TextBaseline TextBaseline `js:"textBaseline"`

	// TextDirection specifies the direction when drawing text.
	TextDirection TextDirection `js:"direction"`

	// FillStyle is the color or style to use inside shapes.
	FillStyle interface{} `js:"fillStyle"`

	// StrokeStyle is the color or style to use for the lines around shapes.
	StrokeStyle interface{} `js:"strokeStyle"`

	// ShadowBlur controls the amount of blur.
	ShadowBlur float64 `js:"shadowBlur"`

	// ShadowColor is the color of the shadow.
	ShadowColor Color `js:"shadowColor"`

	// ShadowOffsetX is the horizonal offset of the shadow.
	ShadowOffsetX float64 `js:"shadowOffsetX"`

	// ShadowOffsetY is the vertical offset of the shadow.
	ShadowOffsetY float64 `js:"shadowOffsetY"`

	// GlobalAlpha is the alpha value that is applied to shapes and images before
	// they are composited onto the canvas.
	GlobalAlpha float64 `js:"globalAlpha"`

	// GlobalCompositeOperation sets how shapes and images are drawn onto the existing bitmap.
	GlobalCompositeOperation CompositeOperation `js:"globalCompositeOperation"`

	// ImageSmoothingEnabled is true if images should be smoothed when scaled.
	ImageSmoothingEnabled bool `js:"imageSmoothingEnabled"`
}

Context2D represents a func (c *Context2D)

func (*Context2D) Arc

func (c *Context2D) Arc(center *Point, radius, startAngle, endAngle float64, clockwise bool)

Arc adds an arc to the path which is centered at center with the specified radius starting at startAngle and ending at endAngle going in the given direction.

func (*Context2D) ArcTo

func (c *Context2D) ArcTo(p, q *Point, radius float64)

ArcTo adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.

func (*Context2D) BeginPath

func (c *Context2D) BeginPath()

BeginPath starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.

func (*Context2D) BézierCurveTo

func (c *Context2D) BézierCurveTo(p, q, r *Point)

BézierCurveTo adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the third one is the end point. The starting point is the last point in the current path, which can be changed using moveTo() before creating the Bézier curve.

func (*Context2D) ClearRect

func (c *Context2D) ClearRect(r *Rect)

ClearRect sets all pixels in the rectangle to transparent black, erasing any previously drawn content.

func (*Context2D) Clip

func (c *Context2D) Clip()

Clip creates a clipping path from the current sub-paths. Everything drawn after calling Clip appears inside the clipping path only.

func (*Context2D) ClosePath

func (c *Context2D) ClosePath()

ClosePath causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing.

func (*Context2D) CreateImageData

func (c *Context2D) CreateImageData() ImageData

CreateImageData creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black.

func (*Context2D) CreateLinearGradient

func (c *Context2D) CreateLinearGradient(start, end *Point) CanvasGradient

CreateLinearGradient creates a linear gradient along the line given by the coordinates represented by the parameters.

func (*Context2D) CreatePattern

func (c *Context2D) CreatePattern(s CanvasImageSource, r Repetition) CanvasPattern

CreatePattern creates a pattern using the specified image and repetition.

func (*Context2D) CreateRadialGradient

func (c *Context2D) CreateRadialGradient(centerA *Point, radiusA float64, centerB *Point, radiusB float64) CanvasGradient

CreateRadialGradient creates a radial gradient given by the coordinates of the two circles and radii.

func (*Context2D) DrawFocusIfNeeded

func (c *Context2D) DrawFocusIfNeeded()

DrawFocusIfNeeded will draw a focus ring around the current path if a given element is focused.

func (*Context2D) DrawImage

func (c *Context2D) DrawImage(srcImage CanvasImageSource, srcRect, dstRect *Rect)

DrawImage draws the specified image.

func (*Context2D) Fill

func (c *Context2D) Fill()

Fill fills the subpaths with the current fill style.

func (*Context2D) FillRect

func (c *Context2D) FillRect(r *Rect)

FillRect draws a filled rectangle.

func (*Context2D) FillText

func (c *Context2D) FillText(text string, p *Point)

FillText draws with a fill the text at the given position.

func (*Context2D) GetImageData

func (c *Context2D) GetImageData(r *Rect) ImageData

GetImageData returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by rect.

func (*Context2D) IsPointInPath

func (c *Context2D) IsPointInPath(p *Point) bool

IsPointInPath returns true if the specified point is contained in the current path.

func (*Context2D) IsPointInStroke

func (c *Context2D) IsPointInStroke(p *Point) bool

IsPointInStroke returns true if the specified point is inside the area contained by the stroking of a path.

func (*Context2D) LineDash

func (c *Context2D) LineDash() []int

LineDash returns the current line dash pattern as an array array containing an even number of non-negative numbers.

func (*Context2D) LineTo

func (c *Context2D) LineTo(p *Point)

LineTo connects the last point in the subpath to p with a straight line.

func (*Context2D) MeasureText

func (c *Context2D) MeasureText(text string) float64

MeasureText returns the measured width of the text.

func (*Context2D) MoveTo

func (c *Context2D) MoveTo(p *Point)

MoveTo jumps the starting point of a new sub-path to p.

func (*Context2D) PutImageData

func (c *Context2D) PutImageData()

PutImageData paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted.

func (*Context2D) QuadraticCurveTo

func (c *Context2D) QuadraticCurveTo(p, q, r *Point)

QuadraticCurveTo adds a quadratic curve to the current path.

func (*Context2D) Rect

func (c *Context2D) Rect(r *Rect)

Rect creates a path for a rectangle.

func (*Context2D) ResetTransform

func (c *Context2D) ResetTransform()

ResetTransform resets the current transformation matrix with identity.

func (*Context2D) Restore

func (c *Context2D) Restore()

Restore restores the drawing style state to the last element on the 'state stack' saved by Save().

func (*Context2D) Rotate

func (c *Context2D) Rotate(angle float64)

Rotate applies a clockwise rotation in angle degrees to the current transformation matrix.

func (*Context2D) Save

func (c *Context2D) Save()

Save stores the current drawing style state using a stack so you can revert any change you make to it using Restore().

func (*Context2D) SaveRestore

func (c *Context2D) SaveRestore() func()

SaveRestore calls Save() and returns Restore. This is a convenience function so you can start a function with:

defer ctx.SaveRestore()()

func (*Context2D) Scale

func (c *Context2D) Scale(x, y float64)

Scale applies a scale to the current transformation matrix.

func (*Context2D) ScrollPathIntoView

func (c *Context2D) ScrollPathIntoView()

ScrollPathIntoView scrolls the current path or a given path into the view.

func (*Context2D) SetLineDash

func (c *Context2D) SetLineDash(pattern []float64)

SetLineDash sets the current line dash pattern.

func (*Context2D) SetTransform

func (c *Context2D) SetTransform(m Matrix)

SetTransform replaces the current transformation matrix with m.

func (*Context2D) Stroke

func (c *Context2D) Stroke()

Stroke strokes the subpaths with the current stroke style.

func (*Context2D) StrokeRect

func (c *Context2D) StrokeRect(r *Rect)

StrokeRect paints a rectangle using the current stroke style.

func (*Context2D) StrokeText

func (c *Context2D) StrokeText(text string, p *Point)

StrokeText draws with a stroke a the text at the given position.

func (*Context2D) Transform

func (c *Context2D) Transform(m Matrix)

Transform multiplies the current transformation matrix with m.

func (*Context2D) Translate

func (c *Context2D) Translate(p *Point)

Translate applies a translation to the current transformation matrix.

type DOMString

type DOMString string

type Display

type Display string

Display is a CSS display enumerator.

const (
	DisplayBlock            Display = "block"
	DisplayFlex             Display = "flex"
	DisplayGrid             Display = "grid"
	DisplayInherit          Display = "inherit"
	DisplayInitial          Display = "initial"
	DisplayInline           Display = "inline"
	DisplayInlineBlock      Display = "inline-block"
	DisplayInlineFlex       Display = "inline-flex"
	DisplayInlineGrid       Display = "inline-grid"
	DisplayInlineTable      Display = "inline-table"
	DisplayListItem         Display = "list-item"
	DisplayNone             Display = "list-none"
	DisplayRunIn            Display = "run-in"
	DisplayTable            Display = "table"
	DisplayTableCaption     Display = "table-caption"
	DisplayTableCell        Display = "table-cell"
	DisplayTableColumn      Display = "table-column"
	DisplayTableColumnGroup Display = "table-column-group"
	DisplayTableFooterGroup Display = "table-footer-group"
	DisplayTableHeaderGroup Display = "table-header-group"
	DisplayTableRow         Display = "table-row"
	DisplayTableRowGroup    Display = "table-row-group"
)

type Div

type Div struct{ *Element }

Div represents an HTML <div> element.

func NewDiv

func NewDiv() *Div

NewDiv returns a new Div element.

func (Div) AppendNode

func (n Div) AppendNode(child Node)

func (Div) Children

func (n Div) Children() []Node

type Document

type Document struct{ *Element }

Document is the root of DOM.

func Doc

func Doc() Document

Doc returns the global document.

func (Document) AppendNode

func (n Document) AppendNode(child Node)

func (Document) Body

func (d Document) Body() *Element

Body returns the document's body element.

func (Document) Children

func (n Document) Children() []Node

type Element

type Element struct {
	Width      int                  `js:"width"`
	Height     int                  `js:"height"`
	OffsetLeft int                  `js:"offsetLeft"`
	OffsetTop  int                  `js:"offsetTop"`
	WidthV     interface{}          `js:"width"`
	HeightV    interface{}          `js:"height"`
	Style      *CSSStyleDeclaration `js:"style"`
	// contains filtered or unexported fields
}

Element is represents a DOM element type.

func (*Element) Append

func (e *Element) Append(v interface{}) Node

Append adds v to the end of element's children. If v is a node then it is simply appended, otherwise the value will be converted to a string and appended as a text node.

func (Element) AppendNode

func (n Element) AppendNode(child Node)

func (Element) Children

func (n Element) Children() []Node

func (*Element) OnClick

func (e *Element) OnClick(cb func(MouseEvent)) Unsubscribe

OnClick registers a click handler for the element.

func (*Element) OnMouseDown

func (e *Element) OnMouseDown(cb func(MouseEvent)) Unsubscribe

OnMouseDown registers a mouse-down handler for the element.

func (*Element) OnMouseMove

func (e *Element) OnMouseMove(cb func(MouseEvent)) Unsubscribe

OnMouseMove registers a mouse-move handler for the element.

func (*Element) OnMouseUp

func (e *Element) OnMouseUp(cb func(MouseEvent)) Unsubscribe

OnMouseUp registers a mouse-up handler for the element.

func (*Element) Text

func (e *Element) Text() Text

Text returns the child text node for the element, creating it if it doesn't already exist.

func (*Element) VisibleRect

func (e *Element) VisibleRect() *Rect

VisibleRect returns the visible region of the element in the viewport.

type ElementProvider

type ElementProvider interface {
	// Element returns the DOM element that represents the type.
	Element() *Element
}

ElementProvider is the interface implemented by types that are represented by a DOM element.

type EventTarget

type EventTarget interface{}

type FlexDirection

type FlexDirection string

FlexDirection is a CSS flexbox direction enumerator.

const (
	FlexColumn        FlexDirection = "column"
	FlexColumnReverse FlexDirection = "column-reverse"
	FlexInherit       FlexDirection = "inherit"
	FlexInitial       FlexDirection = "initial"
	FlexRow           FlexDirection = "row"
	FlexRowReverse    FlexDirection = "row-reverse"
)

type Font

type Font string

Font is a font description.

func NewFont

func NewFont(size int, family string) Font

NewFont returns a new font description with the specified size in pixels and family.

type HashChangeEvent

type HashChangeEvent struct {
	*js.Object

	// NewURL is the new URL to which the window is navigating.
	NewURL DOMString `js:"newURL"`

	// OldURL is the old URL from which the window is navigating.
	OldURL DOMString `js:"oldURL"`
}

HashChangeEvent holds information about a URL hash change.

type ImageData

type ImageData struct{ *js.Object }

type LineCap

type LineCap string

LineCap is an enumerator of line ending styles.

const (
	LineCapButt   LineCap = "butt"
	LineCapRound  LineCap = "round"
	LineCapSquare LineCap = "square"
)

type LineJoin

type LineJoin string

LineJoin is an enumerator of styles where two lines meet.

const (
	LineJoinRound LineJoin = "round"
	LineJoinBevel LineJoin = "bevel"
	LineJoinMiter LineJoin = "miter"
)

type Location

type Location struct {
	*js.Object

	// Hash is the anchor part (#) of a URL
	Hash string `js:"hash"`

	// Host is the hostname and port number of a URL
	Host string `js:"host"`

	// Hostname is the hostname of a URL
	Hostname string `js:"hostname"`

	// Href is the entire URL
	Href string `js:"href"`

	// Origin is the protocol, hostname and port number of a URL
	Origin string `js:"origin"`

	// Pathname is the path name of a URL
	Pathname string `js:"pathname"`

	// Port is the port number of a URL
	Port int `js:"port"`

	// Protocol is the protocol of a URL
	Protocol string `js:"protocol"`

	// Search is the querystring part of a URL
	Search string `js:"search"`
}

Location holds information about a URL

func (Location) OnHashChange

func (Location) OnHashChange(cb func(HashChangeEvent)) Unsubscribe

OnHashChange registers a handler for changes to the Hash of the window's URL.

type Matrix

type Matrix struct {
	A, C, E float64
	B, D, F float64
}

Matrix represents a 3x3 matrix.

╭         ╮
│ A  C  E │
│ B  D  F │
│ 0  0  1 │
╰         ╯

func (*Matrix) Translation

func (m *Matrix) Translation() *Point

Translation returns the translation part of the matrix as a point.

type MouseButton

type MouseButton uint

MouseButton is an enumerator of mouse buttons

type MouseEvent

type MouseEvent struct {
	*js.Object
	// Target represents the event target (the topmost target in the DOM tree).
	// Target EventTarget `js:"target"`
	// Type represents the type of event.
	Type DOMString `js:"type"`
	// Bubbles represents whether the event normally bubbles or not
	Bubbles bool `js:"bubbles"`
	// Cancelable represents whether the event is cancellable or not?
	Cancelable bool `js:"cancelable"`
	// View is the document.defaultView (window of the document)
	View WindowProxy `js:"view"`
	// Detail is a count of consecutive clicks that happened in a short amount
	// of time, incremented by one.
	Detail int `js:"detail"`
	// CurrentTarget is the node that had the event listener attached.
	CurrentTarget EventTarget `js:"currentTarget"`
	// RelatedTarget is used for mouseover, mouseout, mouseenter and mouseleave
	// events: the target of the complementary event (the mouseleave target in
	// the case of a mouseenter event). null otherwise.
	RelatedTarget EventTarget `js:"relatedTarget"`
	// ScreenX is the X coordinate of the mouse pointer in global (screen)
	// coordinates.
	ScreenX int `js:"screenX"`
	// ScreenY is the Y coordinate of the mouse pointer in global (screen)
	// coordinates.
	ScreenY int `js:"screenY"`
	// ClientX is the X coordinate of the mouse pointer in local (DOM content)
	// coordinates.
	ClientX int `js:"clientX"`
	// ClientY is the Y coordinate of the mouse pointer in local (DOM content)
	// coordinates.
	ClientY int `js:"clientY"`
	// PageX is the X coordinate of the mouse pointer in relative to the whole
	// document.
	PageX int `js:"pageX"`
	// PageY is the Y coordinate of the mouse pointer in relative to the whole
	// document.
	PageY int `js:"pageY"`
	// Button is the mouse button pressed when the event was fired.
	// For mice configured for left handed use in which the button actions are
	// reversed the values are instead read from right to left.
	Button MouseButton `js:"button"`
	// Buttons represents the buttons being pressed when the mouse event was
	// fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button
	// (typically, "Browser Back" button)=8, 5th button (typically,
	// "Browser Forward" button)=16. If two or more buttons are pressed, returns
	// the logical sum of the values. E.g., if Left button and Right button are
	// pressed, returns 3 (=1 | 2).
	Buttons uint `js:"buttons"`
	// CtrlKey is true if the control key was down when the event was fired. false otherwise.
	CtrlKey bool `js:"ctrlKey"`
	// ShiftKey is true if the shift key was down when the event was fired. false otherwise.
	ShiftKey bool `js:"shiftKey"`
	// AltKey is true if the alt key was down when the event was fired. false otherwise.
	AltKey bool `js:"altKey"`
	// MetaKey is true if the meta key was down when the event was fired. false otherwise.
	MetaKey bool `js:"metaKey"`
}

MouseEvent holds information about a mouse event.

func (*MouseEvent) PreventDefault

func (m *MouseEvent) PreventDefault()

type Node

type Node interface {
	// Children returns all the child nodes of this node.
	Children() []Node

	// AppendNode adds the child node at the end of the list of children.
	AppendNode(Node)
	// contains filtered or unexported methods
}

Node is the interface implemented by DOM node types.

type Option

type Option struct {
	*Element

	// Selected is true if the option is currently selected.
	Selected bool `js:"selected"`

	// Disabled is true if the option is currently disabled.
	Disabled bool `js:"disabled"`

	// Value is the value of the option.
	Value string `js:"value"`
}

Option represents an HTML <option> element.

func NewOption

func NewOption(text string, value string) *Option

NewOption returns a new Option element.

func (Option) AppendNode

func (n Option) AppendNode(child Node)

func (Option) Children

func (n Option) Children() []Node

type Paragraph

type Paragraph struct{ *Element }

Paragraph represents an HTML <p> element.

func NewParagraph

func NewParagraph() *Paragraph

NewParagraph returns a new Paragraph element.

func (Paragraph) AppendNode

func (n Paragraph) AppendNode(child Node)

func (Paragraph) Children

func (n Paragraph) Children() []Node

type Point

type Point struct{ X, Y float64 }

Point represents a two-dimensional position.

func NewPoint

func NewPoint(x, y float64) *Point

NewPoint returns a new point.

func (*Point) Add

func (p *Point) Add(q *Point) *Point

Add returns a new point with the value of p + q.

func (*Point) Clone

func (p *Point) Clone() *Point

Clone returns a copy of p.

func (*Point) Neg

func (p *Point) Neg() *Point

Neg returns a new point with negated value of p.

func (*Point) Sub

func (p *Point) Sub(q *Point) *Point

Sub returns a new point with the value of p - q.

type Position

type Position string

Position is a CSS position enumerator.

const (
	PositionAbsolute Position = "absolute"
	PositionFixed    Position = "fixed"
	PositionInherit  Position = "inherit"
	PositionInitial  Position = "initial"
	PositionRelative Position = "relative"
	PositionStatic   Position = "static"
)

type Rect

type Rect struct{ TL, BR *Point }

Rect represents a rectangle.

func NewRect

func NewRect(x0, y0, x1, y1 float64) *Rect

NewRect returns a new rect.

func NewRectWH

func NewRectWH(x, y, w, h float64) *Rect

NewRectWH returns a new rect from the top-left point and width and height values.

func (*Rect) Center

func (r *Rect) Center() *Point

Center returns the center point of the rectangle.

func (*Rect) Clone

func (r *Rect) Clone() *Rect

Clone returns a copy of r.

func (*Rect) Contains

func (r *Rect) Contains(p *Point) bool

Contains returns true if rect r contains point p.

func (*Rect) H

func (r *Rect) H() float64

H returns the height of the rectangle.

func (*Rect) Offset

func (r *Rect) Offset(p *Point) *Rect

Offset returns a new rect with the given offset.

func (*Rect) Overlaps

func (r *Rect) Overlaps(s *Rect) bool

Overlaps returns true if rect r overlaps rect s.

func (*Rect) W

func (r *Rect) W() float64

W returns the width of the rectangle.

type Repetition

type Repetition string

Repetition is an enumerator of pattern repetition modes.

const (
	Repeat   Repetition = "repeat"
	RepeatX  Repetition = "repeat-x"
	RepeatY  Repetition = "repeat-y"
	NoRepeat Repetition = "no-repeat"
)

type Select

type Select struct {
	*Element

	// Value is the currently currently selected value.
	Value string `js:"value"`

	// SelectedIndex is the index of the currently selected option.
	SelectedIndex int `js:"selectedIndex"`
}

Select represents an HTML <select> element.

func NewSelect

func NewSelect() *Select

NewSelect returns a new Select element.

func (Select) AppendNode

func (n Select) AppendNode(child Node)

func (Select) Children

func (n Select) Children() []Node

func (*Select) OnChange

func (s *Select) OnChange(cb func()) Unsubscribe

OnChange registers a change handler for the Select element.

func (*Select) Options

func (s *Select) Options() []*Option

Options returns the full list of options added to the select.

type Source added in v0.6.2

type Source struct {
	*Element
	Src string `js:"src"`
	Typ string `js:"type"`
}

func (Source) AppendNode added in v0.6.2

func (n Source) AppendNode(child Node)

func (Source) Children added in v0.6.2

func (n Source) Children() []Node

func (*Source) SetSource added in v0.6.2

func (s *Source) SetSource(source, typ string)

type Span

type Span struct{ *Element }

Span represents an HTML <span> element.

func NewSpan

func NewSpan() *Span

NewSpan returns a new Span element.

func (Span) AppendNode

func (n Span) AppendNode(child Node)

func (Span) Children

func (n Span) Children() []Node

type Table

type Table struct{ *Element }

Table represents an HTML <table> element.

func NewTable

func NewTable() *Table

NewTable returns a new Table element.

func (Table) AppendNode

func (n Table) AppendNode(child Node)

func (Table) Children

func (n Table) Children() []Node

type Td

type Td struct{ *Element }

Td represents an HTML <td> element.

func NewTd

func NewTd() *Td

NewTd returns a new Td element.

func (Td) AppendNode

func (n Td) AppendNode(child Node)

func (Td) Children

func (n Td) Children() []Node

type Text

type Text struct {
	// contains filtered or unexported fields
}

Text represents a text node.

func (Text) AppendNode

func (n Text) AppendNode(child Node)

func (Text) Children

func (n Text) Children() []Node

func (Text) Get

func (t Text) Get() string

Get returns the text content

func (Text) Set

func (t Text) Set(s string)

Set changes the text content to s.

type TextAlign

type TextAlign string

TextAlign is an enumerator of text alignments.

const (
	TextAlignStart  TextAlign = "start"
	TextAlignEnd    TextAlign = "end"
	TextAlignLeft   TextAlign = "left"
	TextAlignRight  TextAlign = "right"
	TextAlignCenter TextAlign = "center"
)

type TextBaseline

type TextBaseline string

TextBaseline is an enumerator of text baselines.

const (
	TextBaselineTop         TextBaseline = "top"
	TextBaselineHanging     TextBaseline = "hanging"
	TextBaselineMiddle      TextBaseline = "middle"
	TextBaselineAlphabetic  TextBaseline = "alphabetic"
	TextBaselineIdeographic TextBaseline = "ideographic"
	TextBaselineBottom      TextBaseline = "bottom"
)

type TextDirection

type TextDirection string

TextDirection is an enumerator of text flow directions.

const (
	TextDirectionLTR     TextDirection = "ltr"
	TextDirectionRTL     TextDirection = "rtl"
	TextDirectionInherit TextDirection = "inherit"
)

type Th

type Th struct{ *Element }

Th represents an HTML <th> element.

func NewTh

func NewTh() *Th

NewTh returns a new Th element.

func (Th) AppendNode

func (n Th) AppendNode(child Node)

func (Th) Children

func (n Th) Children() []Node

type Tr

type Tr struct{ *Element }

Tr represents an HTML <tr> element.

func NewTr

func NewTr() *Tr

NewTr returns a new Tr element.

func (Tr) AppendNode

func (n Tr) AppendNode(child Node)

func (Tr) Children

func (n Tr) Children() []Node

type Unsubscribe

type Unsubscribe func()

Unsubscribe is the function returned by event subscription methods, such as OnClick. Calling Unsubscribe will prevent the event notification from firing again.

type Video added in v0.6.2

type Video struct {
	*Element

	Autoplay bool `js:"autoplay"`
	Controls bool `js:"controls"`
}

Video represents an HTML <video> element

func NewVideo added in v0.6.2

func NewVideo(width, height int, source, typ string) *Video

func (Video) AppendNode added in v0.6.2

func (n Video) AppendNode(child Node)

func (Video) Children added in v0.6.2

func (n Video) Children() []Node

func (*Video) Resize added in v0.6.2

func (v *Video) Resize(width, height int)

type Window

type Window struct {
	*js.Object

	Location         Location `js:"location"`
	DevicePixelRatio float64  `js:"devicePixelRatio"`
	InnerWidth       int      `js:"innerWidth"`
	InnerHeight      int      `js:"innerHeight"`
	// contains filtered or unexported fields
}

Window represents a window that holds a document.

func (*Window) OnLoad

func (w *Window) OnLoad(cb func()) Unsubscribe

OnLoad registers a load handler for the window.

func (*Window) OnScroll

func (w *Window) OnScroll(cb func()) Unsubscribe

OnScroll calles cb whenever the window is scrolled.

func (*Window) RepeatTimer

func (w *Window) RepeatTimer(frequency time.Duration, cb func()) Unsubscribe

RepeatTimer calls cb at the specified frequency until cancelled.

func (*Window) RequestAnimationFrame

func (w *Window) RequestAnimationFrame(cb func()) Unsubscribe

RequestAnimationFrame attempts to call cb as soon as possible.

func (*Window) Timer

func (w *Window) Timer(delay time.Duration, cb func()) Unsubscribe

Timer attempts to call cb after delay duration, unless it is cancelled.

type WindowProxy

type WindowProxy interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL