Skip to content

Commit

Permalink
Merge pull request #5 from ricordisamoa/patch-1
Browse files Browse the repository at this point in the history
fix some typos in README.md
  • Loading branch information
davidmz committed Jan 3, 2015
2 parents 2338f3b + 83ab06d commit 8260878
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ APNG-canvas

([README по-русски](https://github.com/davidmz/apng-canvas/blob/master/README_RU.md))

APNG-canvas is a library for displaing Animated PNG files in the browsers with canvas support (Google Chrome, Internet Explorer 9, Apple Safari).
APNG-canvas is a library for displaying Animated PNG files in the browsers with canvas support (Google Chrome, Internet Explorer 9, Apple Safari).

Working demo: http://davidmz.github.com/apng-canvas/ (around 3 Mb of apng files)

Discussion in LJ: http://david-m.livejournal.com/tag/apng-canvas (in russain)
Discussion in LJ: http://david-m.livejournal.com/tag/apng-canvas (in Russian)

API
-----------

The library creates a global object **APNG**, which has several methods. All methods are asynchronous and most of them receive an optional callback-argument. Methods must be called after DOM tree is loaded.

For deferred calls, these methods return *promise* objects. If jQuery is available, then its [promises](http://api.jquery.com/category/deferred-object/) are used, in other case a compatible interface which supports methods `done`, `fail`, `then` and `always` is used. If the method is finished successfully, `callback` and `done` handlers are called (with the same parameters), in case of error `fail` hendlers are called with the error message.
For deferred calls, these methods return *promise* objects. If jQuery is available, then its [promises](http://api.jquery.com/category/deferred-object/) are used, in other case a compatible interface which supports methods `done`, `fail`, `then` and `always` is used. If the method is finished successfully, `callback` and `done` handlers are called (with the same parameters), in case of error `fail` handlers are called with the error message.

### APNG.ifNeeded(callback?)

Expand All @@ -23,30 +23,30 @@ Other methods (except `checkNativeFeatures`) should be called from the `callback

### APNG.animateImage(img)

This method is called without `callback`. If `img.src` contains a link to the correct APNG file, then this methods creates `canvas`, in which APNG animations would be played.
Then the method selects optimal strategy for animaton depending on the browser:
This method is called without `callback`. If `img.src` contains a link to the correct APNG file, then this method creates `canvas`, in which APNG animations would be played.
Then the method selects optimal strategy for animation depending on the browser:

* For WebKit-based broswers (Chrome and Safari):
* For WebKit-based browsers (Chrome and Safari):
source image is replaced by a transparent gif plus background canvas where the animation is played.
That allows to keep the `img` object, its attributes and event handlers.
* For other browsers (Internet Explorer 9):
Works similar to the `replaceImage` method (below): source image `img` is replaced with `canvas` animation object.

### APNG.replaceImage(img)

This method is called without `callback`. Replaces `img` element (`HTMLImageElement`) with `canvas` animation. Replacement only works when `img` contains correct PNG file. The replacement keeps the attributes of `img`. If jQuery is available, than event handlers are kept too.
This method is called without `callback`. Replaces `img` element (`HTMLImageElement`) with `canvas` animation. Replacement only works when `img` contains correct PNG file. The replacement keeps the attributes of `img`. If jQuery is available, then event handlers are kept too.

This method works the same in all browsers.

### APNG.createAPNGCanvas(url, callback?)

Loads PNG file from that `url` and disassembles it, then creates `canvas` element and starts the animation.

The `callback` is only called when the loaded data contains the correct APNG file. The argument is newly created `canvas` animation element. This element is not a part of the DOM tree, it have to be added manually.
The `callback` is only called when the loaded data contains the correct APNG file. The argument is newly created `canvas` animation element. This element is not a part of the DOM tree, it has to be added manually.

### APNG.checkNativeFeatures(callback?)

Checks if the browser supports `APNG` and `canvas`. Can be called independently from all other methods. The `callback` argument is the objects with two binary fields: `apng` and `canvas`. `True` in those fields means the browser supports correcponding technology.
Checks if the browser supports `APNG` and `canvas`. Can be called independently from all other methods. The `callback` argument is the objects with two binary fields: `apng` and `canvas`. `True` in those fields means the browser supports corresponding technology.


Usage example
Expand All @@ -73,4 +73,4 @@ By the same reason (the use of `XMLHttpRequest`), the library will not work loca

-----------------------------------

Thanks to Max Stepin for the translation of this README.
Thanks to Max Stepin for the translation of this README.

0 comments on commit 8260878

Please sign in to comment.