103 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import Scrollbox from './scrollbox.js'
 | 
						|
 | 
						|
/**
 | 
						|
 * Callback for the switch action.
 | 
						|
 *
 | 
						|
 * @callback actionCallback
 | 
						|
 * @param {object} event - The event object.
 | 
						|
 * @param {Switch} switch - A reference to the switch (also this refers to the switch).
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * Callback for the switch action.
 | 
						|
 *
 | 
						|
 * @callback actionActiveCallback
 | 
						|
 * @param {object} event - The event object.
 | 
						|
 * @param {Switch} switch - A reference to the switch (also this refers to the switch).
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * Callback for the switch beforeAction.
 | 
						|
 *
 | 
						|
 * @callback beforeActionCallback
 | 
						|
 * @param {object} event - The event object.
 | 
						|
 * @param {Switch} switch - A reference to the switch (also this refers to the switch).
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * Callback for the switch afterAction.
 | 
						|
 *
 | 
						|
 * @callback afterActionCallback
 | 
						|
 * @param {object} event - The event object.
 | 
						|
 * @param {Switch} switch - A reference to the switch (also this refers to the switch).
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * Class that represents a PixiJS Switch.
 | 
						|
 * 
 | 
						|
 * @example
 | 
						|
 * // Create the app
 | 
						|
 * const app = new PIXIApp({
 | 
						|
 *     view: canvas,
 | 
						|
 *     width: 900,
 | 
						|
 *     height: 250
 | 
						|
 * }).setup().run()
 | 
						|
 * 
 | 
						|
 * // Create the switch
 | 
						|
 * const switch1 = new Switch({
 | 
						|
 *     x: 10,
 | 
						|
 *     y: 20
 | 
						|
 * })
 | 
						|
 *
 | 
						|
 * // Add the switch to a DisplayObject
 | 
						|
 * app.scene.addChild(switch1)
 | 
						|
 *
 | 
						|
 * @class
 | 
						|
 * @extends PIXI.extras.Scrollbox
 | 
						|
 * @see {@link https://davidfig.github.io/pixi-scrollbox/jsdoc/Scrollbox.html|Scrollbox}
 | 
						|
 * @see {@link https://davidfig.github.io/pixi-viewport/jsdoc/Viewport.html|Viewport}
 | 
						|
 */
 | 
						|
export default class Scrollview extends Scrollbox {
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * Creates an instance of a Switch.
 | 
						|
     * 
 | 
						|
     * @constructor
 | 
						|
     */
 | 
						|
    constructor(opts = {}) {
 | 
						|
 | 
						|
        super(opts)
 | 
						|
 | 
						|
        this.opts = opts
 | 
						|
 | 
						|
        // setup
 | 
						|
        //-----------------
 | 
						|
        this.setup()
 | 
						|
 | 
						|
        // layout
 | 
						|
        //-----------------
 | 
						|
        this.layout()
 | 
						|
    }
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * Creates children and instantiates everything.
 | 
						|
     * 
 | 
						|
     * @private
 | 
						|
     * @return {Scrollview} A reference to the Scrollview for chaining.
 | 
						|
     */
 | 
						|
    setup() {
 | 
						|
 | 
						|
        return this
 | 
						|
    }
 | 
						|
    
 | 
						|
    /**
 | 
						|
     * Should be called to refresh the layout of the Scrollview. Can be used after resizing.
 | 
						|
     * 
 | 
						|
     * @return {Scrollview} A reference to the Scrollview for chaining.
 | 
						|
     */
 | 
						|
    layout() {
 | 
						|
 | 
						|
        return this
 | 
						|
    }
 | 
						|
}
 |