The Dynamic Layer Object API
The Dynamic Layer Object API (DynLayer) is a lightweight object (weighing in at less than 6 KB) that exposes almost all the properties of DHTML layers for both Netscape 4.0 and IE 4.0. I've found it to be the ideal foundation for nearly every application of DHTML. DynLayer targets layers in a similar manner that I've used pointers to target layers. And it has built in properties and methods which make writing cross-browser DHTML a whole lot easier. Using the DynLayer you can put the differences between the browsers aside and concentrate on more important things: building a dynamic website!
I've left the object open-ended, so you can easily customize it to your needs. You can add more methods or properties onto it, or remove whatever parts you feel you won't need. Many of the next lessons in this tutorial will use the DynLayer as the basis for accomplishing some other task, so it is important that you understand how it works and how to use it.
Things that have changed since the last version:
- Now named with a capital "D" to put it in alignment with the rest of my objects.
- Made the code a little more efficient (removed redundancies).
- I've renamed the ref property to doc
- A new event property has been added to allow events like mouseDown, mouseUp, mouseOver, and mouseOut to be applied to the DynLayer
- A new method, setBGColor(), will change the background color of the layer
- The wipe methods have been simplified - instead of wiping each edge independently they clip in unison so they all end at the same time
- Incorporated an addon() method which acts as a "dump-zone", extra properties and methods should be inserted into this method.
- The addon methods - slide, clip, wipe are now defined using the addon() method. Instead of having these methods available to all objects at all times, I've allowed you to selectively choose which of your DynLayers recieve them. This way, only the core methods (hide,show,move) are available to all objects, but the addon methods must be separately assigned using an intializing command: slideInit(), clipInit(), and wipeInit().
- Because the addon methods are less resource demanding, there's little reason to have completely different DynLayer's depending on the application. Therefore I have one standard DynLayer which I will be using across all other parts of this tutorial.
The Dynamic Layer Object
copyright 1998 Dan Steinman