• Home
  • Archives
  • Tag Cloud
  • Contact
Blue Orange Green Pink Purple

Mootools horizontal DIV slider

Tweet
Viewed 33979 times in Web Design since Wednesday, December 26th, 2007 Tags: css, div slider, javascript, mask, mootools, Web Design, website
Dec 26
UPDATE: This tutorial will no longer work as I have migrated by blog to use Mootools 1.2.1
This tutorial has now been rewritten to be compatible with the 1.2.1 version of Mootools
Check out the new 1.2.1 version here

I’ve been playing around with the Mootools javascript framework for over 12 months now. I am by no stretch of the imagination, a savy javascript coder, but can have learnt enough to get by and produce a result both my client and I are happy with.

Using this javascript framework, you can bring your sad static web page to life using only a few lines of code.
You can quickly create collapsible containers, accordions, slide content, and add AJAX to your website and much much more.
I have seen this sliding masked technique used alot and I wanted to replicate it in it’s most basic form.
If this helps anyone beginning to learn Mootools, then please feel free to use it.

It starts off with a masked div, containing a very wide absolutely positioned div which contains the double wide columns, which then contains the four final divs.

HTML Code:

<div id="mask">
    <div id="folio">
      <div class="col">
        <div class="site">
          <h5>adra</h5>
          <a href="http://www.adra.org.nz" target="_blank">
          <img src="/images/portfolio_web_adra.gif" border="0" />
          <span>www.adra.org.nz</span></a>
        </div>
        <div class="site">
          <h5>adrian hodge</h5>
          <a href="http://www.adrianhodge.com" target="_blank">
          <img src="/images/portfolio_web_adrian.gif" border="0" />
          <span>www.adrianhodge.com</span></a>
        </div>
        <div class="site">
          <h5>bienetre</h5>
          <a href="http://www.bienetre.co.nz" target="_blank">
          <img src="/images/portfolio_web_bienetre.gif" border="0" />
          <span>www.bienetre.co.nz</span></a>
        </div>
        <div class="site">
          <h5>billsblog</h5>
          <a href="http://www.billsblog.co.nz" target="_blank">
          <img src="/images/portfolio_web_billsblog.gif" border="0" />
          <span>www.billsblog.co.nz</span></a>
        </div>
      </div>
      <div class="col">
        <div class="site">
          <h5>cablesearch</h5>
          <a href="http://www.cablesearch.co.nz" target="_blank">
          <img src="/images/portfolio_web_cablesearch.gif" border="0" />
          <span>www.cablesearch.co.nz</span></a>
        </div>
        <div class="site">
          <h5>delectable</h5>
          <a href="http://www.delectable.co.nz" target="_blank">
          <img src="/images/portfolio_web_delectable.gif" border="0" />
          <span>www.delectable.co.nz</span></a>
        </div>
        <div class="site">
          <h5>farmmap</h5>
          <a href="http://www.fmsl.co.nz" target="_blank">
          <img src="/images/portfolio_web_farmmap.gif" border="0" />
          <span>www.fmsl.co.nz</span></a>
        </div>
        <div class="site">
          <h5>fionahodge</h5>
          <a href="http://www.fionahodge.com" target="_blank">
          <img src="/images/portfolio_web_fionahodge.gif" border="0" />
          <span>www.fionahodge.com</span></a>
        </div>
      </div>
    </div>
</div>

CSS Styles:

#mask {
	width:505px;
	height:305px;
	overflow:hidden;
	border:1px solid #666;
	position:relative;
	background-color:#999;
	}
#folio {
	position:absolute;
	top:0;
	left:0;
	width:3535px;
	float:left;
}
.col {
	display:block;
	width:505px;
	height:305px;
	float:left;
	}
.site {
	width:233px;
	height:133px;
	float:left;
	padding:5px;
	margin:5px 0 0 5px;
	border:1px solid #666;
	background-color:#FFF;
	font-size:11px;
	font-family:"Courier New", Courier, monospace;
	}

Javascript Function:

function slideFolio(col){
	var x = ((col-1)*-505)
	var folioChange = new Fx.Style('folio', 'left', {duration:2000});
	folioChange.start(x);
	var cur = "trigger"+col;
	$(cur).addClass('current');

	for (i=1;i<=8;i++){
		var loopLI = "trigger"+i;
		if (cur==loopLI){}else{
			$(loopLI).removeClass('current');
		}
	}
}

Result

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7


adra

www.adra.org.nz

adrian hodge

www.adrianhodge.com

bienetre

www.bienetre.co.nz

billsblog

www.billsblog.co.nz

cablesearch

www.cablesearch.co.nz

delectable

www.delectable.co.nz

farmmap

www.fmsl.co.nz

fionahodge

www.fionahodge.com

freos cafe

www.freos.co.nz

hahei horizons

www.haheihorizons.co.nz

hennessys

www.hennessys.co.nz

joshua hodge

www.joshuahodge.co.nz

klm joinery

www.klmjoinery.co.nz

laranicol

www.laranicol.co.nz

living well international

www.adra.co.nz

motogp nz

www.motogp.co.nz

nz bodytalk association

www.nzbodytalk.org.nz

ontheland

www.ontheland.co.nz

paparoa park motels

www.paparoa.co.nz

profiles rotorua

www.profilesrotorua.co.nz

quasimoto

www.quasimoto.co.nz

ranchware

www.ranchware.co.nz

soundwave entertainment

www.adra.co.nz

sportsbike forum

www.sportsbike.co.nz

tumonz

www.tumonz.co.nz

our wedding photos

www.ourweddingphotos.co.nz

11 Comments

  1. Darksoho on March 18th, 2008

    This works well, but there’s still an error coming up.
    An “object not supported” error
    I’m not very JS savvy so could please get some help with this.

  2. Adrian Hodge on March 18th, 2008

    Hi Darksoho,

    What browser are you experiencing that error in? IE?
    Are you using the code exactly as I’ve shown it here?

  3. 123 on May 9th, 2008

    Bhootni ke following hyperlink is not working… http://www.adrianhodge.com/2007/12/26/mootools-horizontal-div-slider/

  4. Adrian Hodge on May 9th, 2008

    It comes to this very same page.
    What do you mean?

  5. Armen on November 6th, 2008

    It’s fun. ATP Subscribe to the RCC perhaps

  6. Rob on January 7th, 2009

    Just wondering, is it possible to use the slider with a newer version of the mootools framework like 1.2.1?

  7. Adrian Hodge on January 7th, 2009

    Hi Rob, I’ve gone ahead and rewritten this tutorial to be compatible with the 1.2.1 Core.
    Just change:

    var folioChange = new Fx.Slide(‘folio’, ‘left’, {duration:1200});
    folioChange.start(x);

    to

    var folioChange = new Fx.Tween(‘folio’, {duration:1200});
    folioChange.start(‘left’,x);

    Or go check out the full updated tutorial here:
    http://www.adrianhodge.com/web-design/mootools-horizontal-div-slider-121/

  8. John on October 20th, 2009

    is there any demo available for such a thing in verttical setting?

    so it scrolls from top to bottom instead of left to right?

  9. Adrian Hodge on October 20th, 2009

    Hi John,

    Try updating the javascript to something like this (untested)

    function slideFolio(col){
    var y = ((col-1)*-<>)
    var folioChange = new Fx.Style(‘folio’, ‘top’, {duration:2000});
    folioChange.start(y);
    var cur = “trigger”+col;
    $(cur).addClass(‘current’);

    for (i=1;i<=8;i++){
    var loopLI = "trigger"+i;
    if (cur==loopLI){}else{
    $(loopLI).removeClass('current');
    }
    }
    }

    You'll also need to change the CSS folio value to extremely tall rather than wide.
    Let me know how you get on.

  10. Aleida Merced on May 30th, 2010

    Hello,just identified your Post when i google something and wonder what hosting do you use for your blog,the speed is more faster than my wordpress, i really need it.will back to check it out,i appreciate it!

  11. Adrian Hodge on May 30th, 2010

    Hey Aleida, my hosting is with Hostdime based in Miami, Florida. USA. http://hostdime.com



Leave a Reply

Adrian Hodge

  • About

    Welcome to the personal website of Adrian Hodge. I'm a web designer/developer living in Rotorua, New Zealand. Married with two lovely kids, I have a love of motorcycles and gadgets. I work for Destination Rotorua Tourism Marketing during the day and run Hodgeman Web & Design after hours.

    Facebook Twitter Google+ YouTube RSS

  • Search


  • NZ accommodation
  • Latest Tweets
    • A great way to end my two week holiday. A MotoTT trackday! (@ Taupo Motorsport Park) [pic]: http://t.co/wEINFoj0 23 hrs ago
    • I've uploaded an @YouTube video http://t.co/pjZ8ur40 MotoTT Taupo Jan 21, 2012 - Track 1 - GoPro Tank Cam 1 day ago
    • Fun with the kids (@ Paekakariki Holiday Park) [pic]: http://t.co/sHfzWRQK 5 days ago
    • More updates...
  • Recent Posts
    • Tweets for the week (2012-02-06)
    • Tweets for the week (2012-01-30)
    • Fabulous Friday Funnies
    • Tweets for the week (2012-01-23)
    • Tweets for the week (2012-01-16)
  • Categories
    • Friday Funnies (266)
    • General Rantings (80)
    • Humour (68)
    • Joshi Jargon (38)
    • Kaylee Rae (4)
    • Music, Movies & Entertainment (18)
    • Podcasts, Gadgets & Tech (7)
    • Rotorua Activities (7)
    • Tweets (99)
    • UTube Picks (22)
    • Web Design (4)
  • Archives
  • Related posts
    • Second year at DRTM
    • Rotorua information website widget
    • Mootools horizontal DIV slider
    • Joshua Hodge gets his own domains
    • Interesting Site of the Week




  • Home
  • Archives
  • Tag Cloud
  • Contact

© Copyright Adrian Hodge. All rights reserved.

Back to Top