Commit Graph

4 Commits

Author SHA1 Message Date
Alistair Buxton
eebfdc1391 Improve the flipping example
Adds tiled images to the viewer at creation so that they are properly
centred.

This also checks the current state of the test checkboxes on loading.
Some browsers, notably Firefox, will remember the value of checkboxes
across reloads. This can lead to the checkboxes being out of sync with
with viewer after a reload.

An alternative is to set autocomplete="off" on each checkbox element.
This will force the browser to reset the field to the default specified
in the HTML. However I think checking the actual value is preferable
as it means the defaults are only specified in one place.
2021-03-23 03:22:13 +00:00
Alistair Buxton
7552806a47 Force reload tiles when the tile's flip doesn't match the image
Flipping an image changes the bounds of each tile. The existing
code assumes that cannot happen. getTile() calculates the tile
bounds the first time it is asked for a particular tile. It then
caches and returns the same time on every subsequent call.

getTile() has a check to test if a tile exists in the cache. If
it does not, the tile is created and inserted. In order to make
tiles be rebuilt after a flip, we only need to check if the tile's
flip matches the image's flip. If not, we can recreate the tile
as if it did not exist.

To make this a bit clearer, the tile's flipped flag is now set
in getTile() rather than positionTile().

This makes setFlip() work.
2021-03-22 06:45:26 +00:00
Alistair Buxton
3161808a9d Add a basic setFlip method to TiledImage
This doesn't fully work - even raising a bounds-change doesn't seem
to be enough.
2021-03-19 17:16:25 +00:00
Alistair Buxton
53052c8c08 Add flipping example
This isn't complete - the flip toggles do not work as setFlip() is
not implemented. The second image is currently always flipped.
2021-03-19 15:45:21 +00:00