Global

Global

Type Definitions

Area

Area object.

{left: number, top: number, right: number, bottom: number}

NameTypeDescription
leftnumber

Left coordinate

topnumber

Top coordinate

rightnumber

Right coordinate

bottomnumber

Bottom coordinate

BBox

Bounding box object.

{x: number, y: number, width: number, height: number}

NameTypeDescription
xnumber

X coordinate

ynumber

Y coordinate

widthnumber

Width of bounding box

heightnumber

Height of bounding box

Intersect

Intersect object.

{pts: Point[], ts1: number[], ts2: number[]}

NameTypeDescription
ptsPoint[]

An array of intersected points, or an empty array if no intersections.

tsArray.<number[]>

Two arrays (0 === first segment, 1 === second segment) of T values for the intersected points.

PathList

Path segment list. Contains an array of objects in the following format:

{type: string, x: number, y: number, x1: number, y1: number, x2: number, y2: number}

NameTypeAttributesDescription
typestring

Valid svg path command limited to M, L, C, Q, Z

xnumber

X coordinate

ynumber

Y coordinate

x1numberoptional

X control point for quadratic and bezier curve

y1numberoptional

Y control point for quadratic and bezier curve

x2numberoptional

Second X control point for bezier curve

y2numberoptional

Second Y control point for bezier curve

lengthnumber

The number of items in the path segment list

Point

Point object.

{x: number, y: number}

NameTypeDescription
xnumber

X coordinate

ynumber

Y coordinate

Methods

.scroll()

Helps to initiate event to trigger scrolling our pretty scroll. Everything else is ignored unless we found a pretty scroll bar in the given target. Across browsers, we are given 2 values to work on; deltaX and deltaY.

  1. deltaX (Returns positive number if you move to the left. Negative if to the right.)
  2. deltaY (Returns positive number if move down. Negative if move up.)

Using deltaX and deltaY, we know which direction you scroll to, and how much pixels you have traversed on your screen when you scroll. However, every browser returns you different number of pixels travelled. We can't take these numbers as face value since they are all so varied. Triggering a scroll just because there is a 1 pixel movement is pretty crazy because it would cause your scrolling to fly off! (Too sensitive)

So we have a minimum number (40px) that we use to determine if a certain amount of pixel traversed is enough to count as a "scroll".

vecta.io BETA