Solved

Jquery Content Flow

Posted on 2011-02-14
7
1,767 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

690 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