pixi-scrollbox icon indicating copy to clipboard operation
pixi-scrollbox copied to clipboard

direct loading of library in README doesn't work for me

Open andrewljohnson opened this issue 3 years ago • 0 comments

The Issue

This code suggested in the README doesn't seem to work for me:

<script src="/static/js/lib/pixi.js"></script>
<script src="/static/js/lib/pixi-viewport.js"></script>
<script src="/static/js/lib/scrollbox.js"></script>
<script>
    const Scrollbox = new Scrollbox(options)
</script>

I get this error: Uncaught ReferenceError: Cannot access 'Scrollbox' before initialization

Related

FWIW, I was also trying to get it to work with requireJS. I am able to get pixi, pixi-filters, and bump loading, but when I try and add in scrollbox, I get errors like Uncaught Error: Script error for "@pixi/math", needed by: pixi-viewport

Sorry if this is just me knowing nothing about node and little about JS builds, or just messing up requirejs syntax!

<script type="text/javascript">
	require.config({
	    paths: {
	        'pixi': '/static/js/lib/pixi',
	        'pixi-filters': '/static/js/lib/pixi-filters',
	        'bump': '/static/js/lib/bump',
	        'scrollbox': '/static/js/lib/scrollbox',
	        'pixi-viewport': '/static/js/lib/pixi-viewport',
	    },
		shim: {         
            'pixi-filters': {
                deps: ['pixi']
            },
            'pixi-viewport': {
                deps: ['pixi']
            },
            'scrollbox': {
                deps: ['pixi', 'pixi-viewport']
            }
        }    	    
	});

	var gameRoom;
	var gameUX;

	require(['pixi', 'pixi-filters', 'bump', 'scrollbox'], function () {
		gameUX = new GameUX();
		gameRoom = new GameRoom(gameUX);
		gameRoom.connect();
		// const Scrollbox = require('scrollbox').Scrollbox
		// const scrollbox = new Scrollbox({ boxWidth: 200, boxHeight: 200})
	});
</script>

andrewljohnson avatar May 12 '21 22:05 andrewljohnson