Weblog

Aaron Boodman's dhtml scroller modifications (ypSimpleScroll)

Hi, i'll show you a hack i made for the mtv spain website this past may. We needed a dhtml scroller that would work with arrows, drag/drop handler and was IE/mac compatible. I couldn't find one at that time, so I took Aaron Boodman's ypSimpleScroll and mixed it with his dom drag script.

The script degrades nicely in (nearly) all browsers, though I've noticed Opera breaks it somewhere, leaving the script half way applied. I haven't had time to investigate, so if any of you want to, you can send me an email. I'll give you an example of the script using text from my tools section.

Example one

Javascript is a different layer of the style and structure ones, and like CSS, it should not be required but optional, so that without its use the page should be accessible and usable. If the browser cannot interpret the code it will not execute it, but the contents will be accessible. This is generally called script degradation. Now, being more specific, what makes a piece of code unobtrusive?

  1. Mix with structure: mainly, script behaviour not being mixed with page contents. This means there will be no intrinsec events inside the document and the file will be stored in a separate .js file.
  2. Initialization: the ideal solution is the script being initialized automatically on page load
  3. Assign actions with an event handler: because we have avoided the use of intrinsec events we will need a way to associate actions (execute functions) to events captured by different elements on the page.
  4. Compatibility: browsers that dont understand the code must do without it throwing no error messages.
  5. Capacities detection: to allow the previous point be true we will use object detection instead of browser detection.

Ending example one.

As you'll see next, I also modified it so the page could handle more than one scroller, even with different sizes, as that was another requirement for that website. So I created a function that added a counter to an array and we pass as arguments the index of that instance and the size for that scroller. The script just does the rest.

Example two

Table of Contents from titles (TOC)

This script reads all nodes in a document and stores the titles hierarchic structure in a variable, showing them in an indented list according to their order. Sections of the list are links to the real section on the page, using the id of the titles (script creates them if needed).

Download toc
Form validator

This script reads all text fields of a form making all "required" classes having to be filled before sent to server, otherwise warning visually and through an alert. If the field is named email it forces (with a regular expression) to use a valid email.

Download validador

Ending example two.

I think it's quite easy to implement, you need:

Download the script in rar format

Once you accomplish these the script will do the rest for you. You can download the script with all the needed files in raw format from here

Comments on this entry

  1. 2004-10-17 04:02:12

    An excellent work, really. That kind of things you'd like to view a Sunday morning. Very well done, mate!.

  2. 2004-10-30 03:59:35

    que poca madre!!! hermoso y hasta lo haces parecer simple... un día quiero llegar a ser como vos... si, raúl como no... a ti lo único que te gusta es la cerveza ;)
  3. 2005-02-03 07:31:02

    • david medina
    • [e]
    no logro encontrar donde se especifican los pixels que puede scrollear la barra del thumb. Es decir yo ahora tengo una caja que hace 250 x 250 pero la barra que scrolea solo me baja hasta 210 y necesito que baje hasta 250, evidentemente un saludo,
  4. 2005-03-16 11:28:54

    Grata sorpresa: El scroll funciona perfectamente en Opera 7.5 bajo windows 2000.
  5. 2005-04-03 11:08:42

    Hello guys, I am currently running in trouble with the script from http://meddle.dzygn.com/eng/weblog/scroller.mod/. The root area in my applicatipon is something about 600x400 px big. I would like to disable the scroller if I have only a few lines to display. For now the scroller is enabled to any point of time even if there is no content in it. This confuses the users somehow and I got requests to change this. Is it something big or is there an elegant way to manage this. Thanks rtg
  6. 2005-04-21 12:13:11

    Muchas gracias!!! tras horas de búsqueda y desespero por fín encuentro una aplicación práctica, sencilla y de fácil personalización... Muchas gracias por facilitarnos el trabajo a tantos...
  7. 2005-05-18 08:22:06

    Fantástico!! Creo que es lo más simple que he visto jamás. Me has ahorrado muchas horas de estudio. A partir de ahora seguiré tu página con interés.
  8. 2005-06-26 06:39:58

    • francisco alejandro barrea
    • [e]
    disculpa soy nuevo y no entendi nada me interesa mucho saver como se ase de una manera ya desarrolada y solo copiarla en el block de notas
  9. 2005-06-26 06:41:46

    • francisco
    • [e]
    me lo podrias mandar a mi mail o ponerlo aqui
  10. 2005-08-04 07:27:47

    Hola. El script me ha parecido muy util ya que es una forma sencilla de hacer un scroll, que es lo que andaba buscando. Lo único, es que me ha parecido un poco lioso definir las propiedades ya que a veces marcan la pauta las css y otras el js. Una cosa que no he logrado es que el texto desaparezca antes de llegar al borde superior y que aparezca un poco antes del borde inferior. Es decir, que igual que queda un margen izquierda-derecha quede un margen arriba-abajo, pero siempre, no solo al inicio. He estado tocando todo lo que se ma ocurrido pero no lo he conseguido. ¿me dirias como se hace?. Venga, un saludo y buen trabajo
  11. 2005-08-04 13:17:51

    Hola Iñaki, En setiembre colgaré una nueva version que tengo medio terminada, a falta de depurar unos pequeños detalles. Ahi se puede modificar muchas mas cosas. Si te puedes esperar a mediados de setiembre... un saludo Sergi

  12. 2005-10-05 04:44:35

    • Diego González
    • [e]
    Hola, muy bueno este script. Solo tengo un problemilla ya que quiero utilizarlo para una pagina que recoge datos de la base de datos y resulta que si el contenido no rellena toda la caja del scroll, me da un error de javascript. Me gustaría saber si esto es así siempre o es que he hecho yo algo mal. Gracias.

Closed

Due to spam bullshit this weblog has been closed to comments, it was impossible to keep my blacklist script updated. You can still figure out my email and send me your message. Sorry.

Change preferences

Change preferences

License

Creative Commons 2001-2004. Sergi Meseguer

RSS syndication

rss (1, 2 ), xhtml, css, taw