Skip to content

Commit

Permalink
Merge pull request #12 from jeanbenitez/typing
Browse files Browse the repository at this point in the history
Added initial definitions for Typescript Support
  • Loading branch information
davidfig authored Dec 2, 2019
2 parents d2345ec + a0d9ffb commit 92005f1
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
114 changes: 114 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import * as PIXI from 'pixi.js'
import { Viewport } from 'pixi-viewport'

type OverflowScrollType = 'none' | 'scroll' | 'hidden' | 'auto'
type UnderflowType = 'center' | 'top' | 'left' | 'right' | 'bottom' | string
interface ResizeOptions {
boxWidth?: number
boxHeight?: number
scrollWidth?: number
scrollHeight?: number
}

interface ScrollBoxOptions {
boxHeight?: number
boxWidth?: number
scrollbarSize?: number
scrollbarBackground?: number
scrollbarBackgroundAlpha?: number
scrollbarForeground?: number
scrollbarForegroundAlpha?: number
dragScroll?: boolean
stopPropagation?: boolean
scrollbarOffsetHorizontal?: number
scrollbarOffsetVertical?: number
underflow?: UnderflowType
fade?: boolean
fadeScrollbar?: boolean
fadeScrollbarTime?: number
fadeScrollboxWait?: number
fadeScrollboxEase?: string | Function
passiveWheel?: boolean
clampWheel?: boolean
overflowX?: OverflowScrollType
overflowY?: OverflowScrollType
overflow?: OverflowScrollType
noTicker?: boolean
ticker?: PIXI.Ticker
}

/**
* pixi.js scrollbox: a masked content box that can scroll vertically or horizontally with scrollbars
*/
export declare class ScrollBox extends PIXI.Container {
boxHeight: number
boxWidth: number
content: Viewport
readonly contentHeight: number
readonly contentWidth: number
dirty: boolean
disable: boolean
dragScroll: boolean
readonly isScrollbarHorizontal: boolean
readonly isScrollbarVertical: boolean
overflow: string
overflowX: string
overflowY: string
scrollbar: PIXI.Graphics
scrollbarOffsetHorizontal: number
scrollbarOffsetVertical: number
scrollbarSize: number
scrollHeight: number
scrollLeft: number
scrollTop: number
scrollWidth: number
stopPropagation: boolean

/**
* create a scrollbox
*/
constructor(options?: ScrollBoxOptions)

/**
* show the scrollbar and restart the timer for fade if options.fade is set
*/
activateFade(): void

/**
* ensure that the bounding box is visible
*/
ensureVisible(x: number, y: number, width: number, height: number): void

/**
* resize the mask for the container
*/
resize(options?: ResizeOptions): void

/**
* call when scrollbox content changes
*/
update(): void

/**
* called on each frame to update fade scrollbars (if enabled)
*/
updateLoop(elapsed: number): void

private _drawMask(): void
private _drawScrollbars(): void

/**
* handle pointer down on scrollbar
*/
private scrollbarDown(e: PIXI.interaction.InteractionEvent): void

/**
* handle pointer move on scrollbar
*/
private scrollbarMove(e: PIXI.interaction.InteractionEvent): void

/**
* handle pointer down on scrollbar
*/
private scrollbarUp(): void
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"description": "a scrollbox built for pixi.js using a masked box that scrolls vertically and/or horizontally with optional scrollbars",
"main": "dist/scrollbox.js",
"module": "dist/scrollbox.es.js",
"types": "@types/index.d.ts",
"directories": {
"doc": "docs"
},
"files": [
"dist"
"dist",
"@types"
],
"scripts": {
"start": "rollup -c rollup.dev.js --watch",
Expand Down

0 comments on commit 92005f1

Please sign in to comment.