Jump to content
Sign in to follow this  

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.

Share this post


Link to post
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');

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...