Hi there! New to this site and new to JS! This place is really impressive! My question is regarding the good old "Moving Boxes" example at http://css-tricks.com/examples/MovingBoxes/ I am wondering how to make it start from the first image (by default it'll start from the 3rd). I started to change basic parameters at the slider.js
// Set up \"Current\" panel and next and prev growBigger(\"#panel_3\"); var curPanel = 3;
I thought this piece of code might be the part controlling that, so i tried changing to 1 instead of 3... It didn't really work, it made the boxes endless and empty and broke the whole design structure I was wondering if anyone can tell me where in the code is the part "telling" the slider to start from 3? and how to change it to the first? I saw a lot of questions like that with no answers on the demo page :)
Another question in the same zone is how can one loop the images? say you have 7 panels so -> click on 7 ---> will show 1. I would like the images to continue and show, even when repeating...
Really hope for any feedback. I know I am not the only newbie here ;-) Thanks in advance Adam
If you look on line 26 of the slider.js file, You will find a line that says
.css('left', "-350px");
This line tells the images to move over so that the 3rd image is lined up in the center. I changed it to be 225px. You can see when you run the script how it affects the script. You can play with the number to move the images. I would start out by setting the number to 0px. This will align the images up to the left of the window. So image 1 will be first. However, I think it looks a lot better if the images get bigger in the middle rather than the end.
Second
If you look on line 102, you will see this code
growBigger("#panel_3")
This code says to make the panel with the id of panel_3 grow bigger.I changed it to ("#panel_1")
then on line 103 you will find
var curPanel = 3;
I changed this to read var curPanel = 1;
The complete changed code is below. Mess with these values to achieve the affect you are looking for. Don't remove any code or the code will stop working. Try instead to set the value to 0 or false.
$(function() {
var totalPanels = $(\".scrollContainer\").children().size();
var regWidth = $(\".panel\").css(\"width\"); var regImgWidth = $(\".panel img\").css(\"width\"); var regTitleSize = $(\".panel h2\").css(\"font-size\"); var regParSize = $(\".panel p\").css(\"font-size\");
var movingDistance = 300;
var curWidth = 350; var curImgWidth = 326; var curTitleSize = \"20px\"; var curParSize = \"15px\";
var $panels = $('#slider .scrollContainer > div'); var $container = $('#slider .scrollContainer');
//direction true = right, false = left function change(direction) {
//if not at the first or last panel if((direction && !(curPanel < totalPanels)) || (!direction && (curPanel <= 1))) { return false; }
//if not currently moving if (($(\"#slider\").data(\"currentlyMoving\") == false)) {
$(\"#slider\").data(\"currentlyMoving\", true);
var next = direction ? curPanel + 1 : curPanel - 1; var leftValue = $(\".scrollContainer\").css(\"left\"); var movement = direction ? parseFloat(leftValue, 10) - movingDistance : parseFloat(leftValue, 10) + movingDistance;
cybershot, Thanks for helping in my first tweaks of JS! Your explanation worked like a charm. Thanks for the example as well! Now I need to payback by actually looping the thing ;-)
New to this site and new to JS! This place is really impressive!
My question is regarding the good old "Moving Boxes" example at http://css-tricks.com/examples/MovingBoxes/
I am wondering how to make it start from the first image (by default it'll start from the 3rd).
I started to change basic parameters at the slider.js
I thought this piece of code might be the part controlling that, so i tried changing to 1 instead of 3... It didn't really work, it made the boxes endless and empty and broke the whole design structure
I was wondering if anyone can tell me where in the code is the part "telling" the slider to start from 3? and how to change it to the first? I saw a lot of questions like that with no answers on the demo page :)
Another question in the same zone is how can one loop the images? say you have 7 panels so -> click on 7 ---> will show 1. I would like the images to continue and show, even when repeating...
Really hope for any feedback. I know I am not the only newbie here ;-)
Thanks in advance
Adam
.css('left', "-350px");
This line tells the images to move over so that the 3rd image is lined up in the center. I changed it to be 225px. You can see when you run the script how it affects the script. You can play with the number to move the images. I would start out by setting the number to 0px. This will align the images up to the left of the window. So image 1 will be first. However, I think it looks a lot better if the images get bigger in the middle rather than the end.
Second
If you look on line 102, you will see this code
growBigger("#panel_3")
This code says to make the panel with the id of panel_3 grow bigger.I changed it to ("#panel_1")
then on line 103 you will find
var curPanel = 3;
I changed this to read var curPanel = 1;
The complete changed code is below. Mess with these values to achieve the affect you are looking for. Don't remove any code or the code will stop working. Try instead to set the value to 0 or false.
Your explanation worked like a charm.
Thanks for the example as well!
Now I need to payback by actually looping the thing ;-)
Adam.