basic-features.mustache revision abf8b2e249b86b7bc5986c3e2478a9ba026b74e6
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe<h2>Basic Trigger examples</h2>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe<div class="intro">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Displayed here are some basic triggers of the ImageLoader Utility.
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov Each image group has an assigned action that will make the group of image(s) appear.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe #group1, #group2, #group3, #group4 { border-bottom: dotted 1px #ccc;}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe .yuiLogo { width:117px; height: 52px; border:1px solid #888; margin:5px;}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe<div class="example">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div id="group1">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h3>Group 1: Two second delay</h3>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <p>This will appear two seconds after page-load.</p>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div class='yuiLogo' id='delay' title='Group 1: 2 sec limit'></div>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h5>HTML</h5>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div id='delay' title='Group 1: 2 sec limit'></div>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h5>JavaScript</h5>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe var delayGroup = new Y.ImgLoadGroup({ timeLimit: 2 });
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe delayGroup.registerImage({ domId: 'delay', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div id="group2">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h3>Group 2: Window scroll event</h3>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <p>This will appear when the scroll event is fired.</p>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div class='yuiLogo' title='Group 2: scroll'>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <img id='scroll' style='visibility:hidden;' />
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov <h5>HTML</h5>
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov <img id='scroll' style='visibility:hidden;' />
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h5>JavaScript</h5>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe var scrollGroup = new Y.ImgLoadGroup();
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe scrollGroup.registerImage({ domId: 'scroll', srcUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true, setVisible: true });
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe scrollGroup.addTrigger(window, 'scroll');
var mouseoverGroup = new Y.ImgLoadGroup();
mouseoverGroup.registerImage({ domId: 'scroll', srcUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true, setVisible: true });
mouseoverGroup.addTrigger(window, 'scroll');
var clickGroup = new Y.ImgLoadGroup();
clickGroup.registerImage({ domId: 'duo1', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
clickGroup.registerImage({ domId: 'duo2', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
clickGroup.addTrigger('#duo2', 'click').addTrigger('#duo1', 'click');
var delayGroup = new Y.ImgLoadGroup({ timeLimit: 2 });
delayGroup.registerImage({ domId: 'delay', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
var scrollGroup = new Y.ImgLoadGroup();
scrollGroup.addTrigger(window, 'scroll');
scrollGroup.registerImage({ domId: 'scroll', srcUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true, setVisible: true });
var mouseoverGroup = new Y.ImgLoadGroup();
mouseoverGroup.addTrigger('#mouseover', 'mouseover');
mouseoverGroup.registerImage({ domId: 'mouseover', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
var clickGroup = new Y.ImgLoadGroup();
clickGroup.addTrigger('#duo2', 'click').addTrigger('#duo1', 'click');
clickGroup.registerImage({ domId: 'duo1', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
clickGroup.registerImage({ domId: 'duo2', bgUrl: 'http://stage.yuilibrary.com/img/yui-logo.png', isPng: true });
The ImageLoader Utility allows you to define the conditions under which images are loaded into the page.
Simply make sure the <code><img></code> elements have <code>id</code> attributes, eliminate the <code>src</code> attribute