target: "timeline",
title: "This is a title",
text: "this is some interesting text that goes inside",
- innerHTML: "Click here for <a href='http://www.google.ca'>Google</a>"
+ innerHTML: "Click here for <a href='http://www.google.ca'>Google</a>" ,
+ direction: "down"
} )
.timeline({
start: 3, // seconds
target: "timeline",
title: "double as interesting",
text: "this is some interesting text that goes inside",
- innerHTML: "Maybe a button? <button onClick=\"window.location.href='http://www.google.com'\">Click Me</button>"
+ innerHTML: "Maybe a button? <button onClick=\"window.location.href='http://www.google.com'\">Click Me</button>",
+ direction: "down"
} )
.timeline({
start: 7, // seconds
target: "timeline",
title: "3x as interesting",
text: "this is some interesting text that goes inside",
- innerHTML: ""
+ innerHTML: "",
+ direction: "down"
} )
.timeline({
start: 9, // seconds
"<td>row 2, cell 1</td>" +
" <td>row 2, cell 2</td>" +
"</tr>" +
- "</table>"
+ "</table>",
+ direction: "down"
} )
.timeline({
start: 14, // seconds
target: "timeline",
title: "5x as interesting",
text: "this is some interesting text that goes inside",
- innerHTML: "Click here for <a href='http://www.apple.com'>Apple</a>"
+ innerHTML: "Click here for <a href='http://www.apple.com'>Apple</a>",
+ direction: "down"
} )
.timeline({
start: 18, // seconds
target: "timeline",
title: "6x as interesting",
text: "this is some interesting text that goes inside",
- innerHTML: ""
+ innerHTML: "",
+ direction: "down"
} );
}, false);
</script>
* -Title is the title of the current timeline box
* -Text is text is simply related text that will be displayed
* -innerHTML gives the user the option to add things such as links, buttons and so on
+ * -direction specifies whether the timeline will grow from the top or the bottom, receives input as "UP" or "DOWN"
* @param {Object} options
*
* Example:
Popcorn.plugin( "timeline" , function( options ) {
var target = document.getElementById( options.target );
- target.style.float = "left";
target.style.width = "400px";
target.style.height = "200px";
target.style.overflow = "auto";
// that already exists in the parent div gets overwritten
var newdiv = document.createElement( "div" );
newdiv.style.display = "none";
- newdiv.id = "timelineDiv"+i;
+ newdiv.id = "timelineDiv" + i;
+
+ options.direction = ( options.direction.toLowerCase() === "up" || options.direction.toLowerCase() === "down" )
+ ? options.direction : "up";
if ( target ) {
target.appendChild( newdiv );
// if this isnt the first div added to the target div
- if( i ){
-
+ if( i && options.direction.length === 2 ){
// insert the current div before the previous div inserted
target.insertBefore( newdiv, document.getElementById( "timelineDiv" + ( i - 1 ) ) );
- }
+ }
+
+ target.scrollTop = options.direction.toLowerCase() === "down" ? 0 : target.scrollHeight;
}
i++;
return {
- start: function( event, options ){
+ start: function( event, options ) {
newdiv.style.display = "block";
},
- end: function( event, options ){
+ end: function( event, options ) {
newdiv.style.display = "none";
},