Solved

Jquery Content Flow

Posted on 2011-02-14
7
1,721 Views
Last Modified: 2012-05-11
Hi,

I've implemented the following component - http://www.jacksasylum.eu/ContentFlow/index.php - however I'm unable to figure out how to make the items closer together.

Can someone please advise me how the best way to do this would be?

Many thanks in advance.
0
Comment
Question by:Webbo_1980
  • 4
  • 3
7 Comments
 
LVL 3

Expert Comment

by:thecrew
ID: 34889167
I haven't played with it but just glancing at the coverflow.js file I would say a good place to start would be to mess with the math around lines 271 and maybe 1658

lines starting at 271:
    calcSize: function (x, f) {
        var h = this.maxHeight/(Math.abs(x)+1);
        var w = h;

        return {width: w, height: h};
    },

    calcPosition: function (x, f, size) {
        var X = x * size.width * 2;
        var Y = - this.flowCenter.y + size.height/2;  // bottom
        return {x: X, y: Y};

    },

Open in new window



lines starting at 1658:
  
             /* set position */
            Item.style.left = this.flowCenter.x + position.x - size.width/2 + "px";
            Item.style.top = this.flowCenter.y - position.y - size.height/2 + "px";

Open in new window


It appears to me that those are the lines that have something to do with the position of the images. Since the image positions and sizes change dynamically as the images scroll across there is not going to be a CSS margin or anything that you can set. It has to be calculated per image and per "frame", that's what the JavaScript does.

Let me know if that works!

0
 

Author Comment

by:Webbo_1980
ID: 34891349
Hi

Many thanks for this - I think I'm probably doing something wrong - as I'm unable to find this in the coverflow.js - can you provide any help?

Thanks,

Webbo
0
 
LVL 3

Expert Comment

by:thecrew
ID: 34892377
I'm sorry, I meant to say contentflow not coverflow... What are you using to look at the contentflow.js file (dream weaver, notepad, textedit etc. etc.)?

This is the file I was looking at: http://www.jacksasylum.eu/ContentFlow/contentflow.js

That's the file that the example on their website uses.
Maybe I'm misunderstanding the problem at hand.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Webbo_1980
ID: 34892566
Hi

Thanks for this :-)

The javascript I've used has been downloaded from the following link - http://www.jacksasylum.eu/ContentFlow/download.php.

Any help would be great.

Thanks,

Webbo
0
 
LVL 3

Accepted Solution

by:
thecrew earned 500 total points
ID: 34892679
Okay, to make that code legible...

1. Copy that piled together mess of code
2. Go to http://jsbeautifier.org/
3. Paste it in the text area and click "Beautify"
4. Copy those results back into your .js file and save it

Now, on line 639 you'll see this:
        calcSize: function (D) {
            var B = D.relativePosition;
            var C = 1 / (Math.abs(B) + 1);
            var A = C;
            return {
                width: A,
                height: C
            }
        },
        calcCoordinates: function (C) {
            var B = C.relativePosition;
            var E = this.conf.visibleItems;
            var D = 1 - 1 / Math.exp(Math.abs(B) * 0.75);
            var A = C.side * E / (E + 1) * D;
            var F = 1;
            return {
                x: A,
                y: F
            }
        },

Open in new window



and line 1739 has this:  _positionItem: function (S, A) {...
and line 1781 has this:  _scaleImageSize: function (N, P, I) {...

Both of those look suspect. Again I haven't tried anything. The dynamically created CSS is positioning and sizing the images using position:absolute and top and left coordinates. Perhaps those are being calculated at lines 1739 etc. Back up the .js file then play with numbers and see what happens, it's a great way to learn too!
Let me know what you come up with!
0
 

Author Comment

by:Webbo_1980
ID: 34892873
thank you that worked perfectly!
0
 
LVL 3

Expert Comment

by:thecrew
ID: 34892956
Awesome! Well done!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now