Jump to content

Recommended Posts

hey guys l just finished learning javascript and want to build a simple image slider. l tried using array but it just won't slide l would like to know to build one without jquery. you can direct me to a site that explains the process or just paste the code here..thanks ahead.

Link to comment
Share on other sites

An array is just a data structure, it only holds data. If you want to do animation in Javascript then you need to use timeouts. If you search for Javascript animation you should be able to find several examples.

 

The basic idea is that you use CSS to move the position of an element, and you set it up to run a function maybe every 10 milliseconds which moves the element by a little bit, until it's where you want it. Javascript uses setTimeout and setInterval to run a function later. So you could do something like this to move an element left by 100 pixels:

function move_element(id) {  var el = document.getElementById(id);  var target = -100;  var current = parseInt(el.style.left, 10);  if (isNaN(current)) {    current = 0;  }  current--;  el.style.left = current + 'px';  if (current != target) {    setTimeout('move_element("' + id + '")', 10);  }} move_element('some_id');
Link to comment
Share on other sites

I'd like to know where these terms are defined and by who.

 

Slider? Modal? Lightbox?

 

Do these words have well defined meanings or are they vague concepts?

 

What other words are in this vocabulary?

Edited by davej
Link to comment
Share on other sites

I guess a slider is something that slides. A modal box is a box that blocks everything else, where you can't click on anything other than the box. Javascript's alert box is modal, you can't interact with the rest of the page while an alert box is open, you need to close the alert first. Lightbox is probably a brand name that people made into a generic term, like Xerox or Kleenex.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...