Creating pointers
In Point it out, we call "pointer" to created and absolutely positioned elements via the create() function.
import { create } from 'pointitout'
create('rect', { target: '#target-css-selector' })
Common params and options for all pointers
create ( pointerType, options )
Common params and options for all SVG pointers
SVGOptions
Rect
The first and most basic pointer. In addition to the options described above, this pointer has the following specific options:
create ( 'rect', options )
Examples
Notice the use of "container" option to create the SVG inside the <main> element instead body, avoiding issues with the scrollable main.
create('rect', {
target: '#box-1',
container: 'main',
padding: 8,
animate: 'pulse'
})
create('rect', {
target: '#box-2',
container: 'main',
strokeWidth: 8,
strokeColor: '#68c'
})
create('rect', {
target: '#box-3',
container: 'main',
strokeColor: '#f8c',
round: '30%',
padding: 12
})
Free pointer
Uses an HTML or SVG element as a pointer.
In addition to the common options for all pointers, this pointer has the following specific options:
create ( 'free', options )
Examples
Notice the use of "container" option to create the pointer inside the <main> element instead body, avoiding issues with the scrollable main of this site.
create('free', {
target: '#box-f1',
pointerElement: '#sword',
container: 'main'
})
create('free', {
target: '#box-f2',
pointerElement: '#div-pointer',
container: 'main',
transformOrigin: 'right',
fromAngle: 160,
distance: 20,
animate: 'pulse'
})
Arrow
A kind of free pointer that uses a procedurally generated SVG arrow as pointer element. Has SVG options and the free pointers options (except pointerElement).
Examples
Notice the use of "container" option to create the SVG inside the <main> element instead body, avoiding issues with the scrollable main.
// Default: bottom-right orange
// arrow without stroke
create('arrow', {
target: '#box-1b',
container: 'main'
})
create('arrow', {
target: '#box-2b',
container: 'main',
strokeWidth: 8,
strokeColor: '#46a',
fillColor: '#8bf',
fromAngle: 150,
animate: 'pulse'
})
create('arrow', {
target: '#box-3b',
container: 'main',
fillColor: '#7f7',
fromAngle: 'right top',
distance: 50
})
Pointer references
The create function returns a reference to a Pointer instance, an object with some useful methods to manipulate it. Also contains a reference to the target element and the created raw HTMLElement.
import { create } from 'pointitout'
const pointer = create('rect', { target: '#target-element-id' })
// You can access to the target element and the raw
// created HTMLElement from this object if you need
console.log(pointer.target)
console.log(pointer.htmlElement)
// Some pointers method. See next sections.
pointer.update() // Update the pointer
pointer.destroy() // Destroy the pointer