PxLoader is a Javascript library that helps you download images, sound files or anything else you need before you take a specific action on your site (like showing a user interface or starting a game). You can use it to create a preloader for HTML5 games and websites. Details and examples: http://thinkpixellab.com/pxloader/ The MIT License Copyright (c) 2012 Pixel Lab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.
Overview
Comments
-
Plugin improvements
Various plugin improvements:
- Enable setting
responseType
for PxLoaderData's internal XHR to allow requests for data other than plain-text (e.g. Blob data) - Fixed PxLoaderData triggering load handler with partial data for large requests
- Release HTTP connections used by PxLoaderAudio and PxLoaderVideo after loading is completed, closes #53
- Normalized plugin APIs: replaced
origin
parameter used by PxLoaderAudio, PxLoaderImage and PxLoaderVideo withoptions
hash for all plugins - Refactored PxLoaderAudio, PxLoaderImage and PxLoaderVideo to reduce code duplication
- Enable setting
-
CommonJS support
The way exports are defined in PxLoader are incompatible with CommonJS. The PxLoader script becomes un-scoped from the window, so exporting to
this
is useless.CommonJS support can be added with this line:
if(module && module.exports) module.exports = PxLoader;
-
PxLoaderImage throws exception when options is undefined
This code used to work:
pxImage = new PxLoaderImage(src);
It now throws an exception as of version 1.1.1:
PxLoaderImage.js:24 Uncaught TypeError: Cannot read property 'origin' of undefined
A workaround is to pass in an empty options object:
pxImage = new PxLoaderImage(src, undefined, undefined, {});
-
GIF images skipping to end on IE
For some reason, in IE, after pre loading an animated gif and placing it on the page, the animation is on the last frame (for non-looping gifs). Examlpe of issue: http://jsfiddle.net/xJveS/4/
-
Full preload video
I have to load a lot of videos. PXLoader could help me do that. For now, video continues to load but the addCompletionListener() function is already running. While reading, I realized that this is the browser that managed if the video could be played. But I 'd like the video is fully charged for not having buffering after the loader.
Is it possible to force the full load media ? Thank you
-
PxLoader on NPM
Hi!
I really like PxLoader and I use it on every project I do. But I would like to install the library with NPM instead of Bower. Is it possible to do this ? :)
-
Add Bower
I'm adding this library to the bower registry under my user/repo, I'll gladly remove it once this has been merged and we can add it again under the Pixel Lab account.
fixes #30
-
AMD support
Even tough there seems to be some work done for providing AMD compatibility, there are some inconsistencies that may still fail.
For example, I can have:
define [ 'pxloader' 'pxloaderimage' 'pxloadersound', 'pxloadervideo' ], ( pxloader, pxloadersound, pxloaderimage, pxloadervideo)-> # code here...
Which may fail, since
PxLoaderimage
,PxLoaderSound
andPxLoaderVideo
will try to add some methods onPxLoader
prototype through it's global definition.PxLoader.prototype.addVideo = function(url, tags, priority) { PxLoader.prototype.addSound = function(id, url, tags, priority) { PxLoader.prototype.addImage = function(url, tags, priority) {
As AMD do not load files orderly, the
sound
,image
andvideo
plugins may finish loading first, specially because they are much smaller. And every time it happens, an error will be raised.Uncaught ReferenceError: PxLoader is not defined
In order to fix this, this raw prototype calls should be made as a AMD
require
as well in casedefine
andamd.define
is present, so thePxLoader
reference will never beundefined
. -
addCompletionListener callback parameter
The documentation shows callbacks supplied to addCompletionListener get called with an event parameter, but it appears they don't. It would actually be useful if they did.
-
images do not download in order specified by tags
I have the following:
loader = new PxLoader(); //title page for(var i=0; i<titlePageImages.length; i++) { pxImage = new PxLoaderImage(titlePageImages[i], "titlePage"); pxImage.imageNumber = i + 1; loader.add(pxImage); } loader.addProgressListener(function(e) { console.log("titlePage: " + e.completedCount + ' / ' + e.totalCount); }, "titlePage"); loader.addCompletionListener(function(e) { console.log('Title Page Loaded'); }, "titlePage"); //main for(i=0; i<mainImages.length; i++) { pxImage = new PxLoaderImage(mainImages[i], "main"); pxImage.imageNumber = i + 1; loader.add(pxImage); } loader.addProgressListener(function(e) { console.log("main: " + e.completedCount + ' / ' + e.totalCount); }, "main"); loader.addCompletionListener(function(e) { console.log('Main Assets Loaded'); }, "main"); loader.start(["titlePage", "main"]);
And I am getting this output in the console:
titlePage: 1 / 7 titlePage: 2 / 7 titlePage: 3 / 7 titlePage: 4 / 7 main: 1 / 17 main: 2 / 17 main: 3 / 17 main: 4 / 17 main: 5 / 17 titlePage: 5 / 7 main: 6 / 17 main: 7 / 17 main: 8 / 17 main: 9 / 17 main: 10 / 17 main: 11 / 17 main: 12 / 17 main: 13 / 17 main: 14 / 17 main: 15 / 17 titlePage: 6 / 7 main: 16 / 17 titlePage: 7 / 7 Title Page Loaded main: 17 / 17 Main Assets Loaded
As you can see the elements tagged with "main" start downloading before the "titlePage" elements have completed.
-
Cannot read property 'origin' of undefined
PxLoaderImage.js is causing an error due to these lines of code:
if (options.origin) { img.crossOrigin = options.origin; }
This is how I'm defining the loader:
loader = new PxLoader(); loader.add(new PxLoaderImage('images/arrow-bottom.jpg'));
A user reported this and then closed the topic, saying he solved it by "passing in all the args", but he didn't post his code solution. I don't know what arguments the loader needs. Help?
And since I have the topic open, one more question: when you say PxLoaderSound.js "works with SoundManager 2", does that mean I need to download that API? What order should I load it in (before or after the px files)?
-
Advice on how to write a plugin for inline or async data operations (e.g. promises)
Hi, have been using this library for years - thanks for the efforts on this. I've been mulling over whether it's possible for a plugin to handle asynchronous/promise operations? A couple of use cases:
- ~~I'm pulling data asynchronously from a remote api, I want pxloader to wait for the data to come in~~. I just saw that there is a PxLoaderData plugin for this use case.
- I'm running internal data handling logic that involves the use of a promise. I want pxloader to wait for the promise to resolve.
I took a quick look at some of the existing plugins but didn't have time to dig into them. I imagine others must have this same use case in their apps. So my question at this point is, what is the best approach here: write a custom plugin that ties all of this into pxloader or handle these types of async/promise operations outside of pxloader?
If it's the latter, the issue is then how to seamlessly integrate into pxloader's progress/complete logic and handlers?
Thanks in advance for any guidance/info on this.
-
RequireJS issue v1.1.0
Starting with v1.1.0 of PxLoader, I am now getting the following error when including it in my code.
require.js:168 Uncaught Error: Script error for "pxloader", needed by: app/Sounds, utils/resizer
Neither of the scripts listed use PxLoader in anyway, so I am a little confused by the error.
I have a path set to point to pxloader's folder in my requirejs config.
paths: { jquery: '../bower_components/jquery/dist/jquery.min', greensock: '../bower_components/greensock/src/minified', pxloader: '../bower_components/PxLoader/dist' },
And in the file that produces the error....
if (typeof define === 'function' && define.amd) { define( [ 'jquery', 'pxloader/pxloader-all' ], function () {...
PxLoader 1.0.2 and backwards work ok. This error is new to 1.1.0.
Anyone suggestions of how to resolve it would be appreciated.
-
gulping with babel produces errors
Not sure if this has been addressed already but when I gulp pxloader.js with babel
.pipe($.babel())
it returns a couple "PxLoader is not defined" errors. -
Numbers should not jump in "addProgressListener ". For eg. - 10, 11, 12, 13 ... instead of 10, 12, 15, 20.
hello! Great plugin, have been using the same for couple of my websites.
Our client has a requirement that can we have the plugin output the numbers in "addProgressListener " in a smooth transition For example - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ... instead of 10, 12, 15, 20.
Not sure if its possible with adding a variable and using setTimeout,etc. But that would be too complicated.
Thanks.
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt
Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np
Kurs-repo för kursen Webbserver och Databaser
Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi
MLPleaseHelp is a simple ML resource search engine.
README MLPleaseHelp is a simple ML resource search engine. How To Use You can use this search engine right now at https://jgreenemi.github.io/MLPlease
JS Cloudimage 360 View - A simple, interactive resource that can be used to provide a virtual tour of your product
JS Cloudimage 360 View - A simple, interactive resource that can be used to provide a virtual tour of your product
Palaemon is an open-source developer tool for monitoring health and resource metrics of Kubernetes clusters and analyzing Out of Memory (OOMKill) errors
Palaemon ?? ?? An Electron based developer tool for Kubernetes cluster monitoring and error analysis Palaemon is a Greek, child sea-god who came to ai
A new Node.js resource built using Gatsby.js with React.js, TypeScript, and Remark.
Nodejs.dev Nodejs.dev site built using Gatsby.js with React.js, TypeScript, SCSS, and Remark. You can find the latest Figma design protype here. ?? Ge
This tool allows you to draw up plans for facilities from Foxhole's new Inferno update. It takes power and resource needs into account to help you efficiently design your facilities.
Foxhole Facility Planner This tool allows you to draw up plans for facilities from Foxhole's new Inferno update. It takes power and resource needs int
Utility for collecting resource-based policies from an AWS account
AWS resource-based policy collector This library aims to collect resource-based policies from an AWS account. NOTE: This library does not cover all AW
Cache Solidjs resources by key (derived from the resource source)
Solid Cached Resource (Experimental) Create a solid resource attached to a cached state by a unique key. Heavily inspired by react-query, but for soli
Sanity plugin for viewing resources which reference a particular resource.
@indent-oss/sanityio-referenced-by Plugin to see which documents reference a particular document referenced-by-sanityio.mov Video Alt Text: Demonstrat
This document introduces an early implementation of the Node-RED runtime that runs on resource-constrained microcontrollers (MCUs).
Node-RED MCU Edition Copyright 2022, Moddable Tech, Inc. All rights reserved. Peter Hoddie Updated June 25, 2022 Introduction This document introduces
Open apps directly in GNOME Software by clicking Install from Flathub and apps.gnome.
Flatline Open apps directly in GNOME Software by clicking Install from Flathub and apps.gnome. Load the extension in Firefox Clone the repository Open
Sample apps showing how to build music and video apps for Xbox using a WebView.
description languages name page_type products urlFragment Sample showing how to build music and video apps using primarily web technologies for Xbox.
why make apps to increase focus -- when you can make apps to reduce focus
impossifocus ?? What is this? ImpossiFocus will measure focus by reading your brainwaves -- and if you're in the zone, it'll ensure that changes with
Simple format that serves it's one and only purpose and that's creating simple task list everywhere where you can write plain text
SWTF (Simple Worklog Task Format) Simple format that serves it's one and only purpose and that's creating simple task list everywhere where you can wr
In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaScript index file that imported all the modules and assets
To Do List In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaSc
A simple, lightweight, clean and small library for creating guided product tours for your web app.
Tourguide.js Simple, lightweight library for creating guided tours for your web, apps and more. A tour guide is a person who provides assistance, info
A simple easy to use vanilla JavaScript library for creating input fields that accept multiple email addresses
MeiMei - Multiple Email Input MeiMei: A simple easy to use vanilla JavaScript library for creating input fields that accept multiple email addresses.
Simple To-do list build using HTML5, CSS3, JavaScript and Webpack. You can add new tasks, remove and edit them.
Simple To-do list build using HTML5, CSS3, JavaScript and Webpack. You can add new tasks, remove and edit them.