I'm wondering if there is a callback I can use or some other means of running a small bit of code every time the slide changes. Essentially I want to make an change in the "activeslide" div to show users which slide is active. I know some can be done with CSS, but my goal is to fade out a canvas element on the active slide, then fade it back in when it's not active.

CommentFileSizeAuthor
#8 screen.png25.9 KBArkrep

Comments

TelFiRE’s picture

So no call back for this then? I have to modify the module?

Arkrep’s picture

You could look at the Jquery cycle plugin advance settings

http://malsup.com/jquery/cycle/options.html

Arkrep’s picture

Well it would seem the problem that I am working on at the moment is going to call for me to use callbacks and I thought it best to add what I find here to help others that might come across this post.

Anyway it is indeed possible to use the advanced functions of the Jquery cycle plugin to call other functions before and after a slide has transitioned.

See the callback section of the Jquery cycle plugin examples

http://malsup.com/jquery/cycle/int2.html

TelFiRE’s picture

Steven, thanks a lot for the resources, the first I've seen but the second was new info. However I am not understanding how this is implemented, when I run the code as it is shown on that example it doesn't work with views slideshow. Do I need some module to make Views Slideshow use the cycle plugin and respect its callbacks?

Edit, ok with a lot of trial and error I've started to understand how it's supposed to work -- I define the functions in my jQuery but put the options in the advanced options field. But my syntax is wrong or something, no matter what I do I get uncaught type error that onBefore() has no method 'apply'

Someone should really take it upon themselves to document this stuff. It is absolutely awful documentation, and it's sad, because all the information is there, yet people waste dozens of hours on problems like this because there isn't a simple EXAMPLE of actual REAL WORLD use. :(

TelFiRE’s picture

http://stackoverflow.com/questions/3919773/jquery-cycle-plugin-callback-...

I found this document which gave me some false hope, unfortunately the problem still occurs. When I tried creating and calling the function directly in the advanced options I get a Uncaught SyntaxError: Unexpected token null. This occurs in the middle of my freaking doctype.

I'm about to slaughter something.

Arkrep’s picture

Hi TelFiRE,

I've been playing with this for a couple of days and I've managed to get it working. Here's a couple of points that might point you (or anyone else who comes across this post) in the right direction.

First you need to make sure that the cycle plugin is installed. Which is optional to the views slideshow module. Once this is installed correctly you should have the cycle options available to you in the settings dialog box for the views slideshow.

Second you should enter your function code directly into the textarea of the advanced cycle plugin settings with "before" or "after" selected from the dropdown WITHOUT it being wrapped in a function. so for example.

function onBefore() { 
    $('#output').html("Scrolling image:<br>" + this.src); 
} 

Would simply become

    $('#output').html("Scrolling image:<br>" + this.src); 

If you could post up your code I'll have a look and see if I can help you out a bit more.

TelFiRE’s picture

Thanks Steven.

In my jQuery I define the functions:

function onBefore(){
	$(".activeSlide .overlayed canvas").animate({opacity:1},"slow");
} function onAfter(){
	$(".activeSlide .overlayed canvas").animate({opacity:0},"slow");
}

Then in the Advanced Options box for views slideshow, I have tried several variations to no avail.

before:onBefore(),
after:onAfter()
before:onBefore()
after:onAfter()
before:onBefore
after:onAfter
'before':'onBefore'
'after':'onAfter'

And they all give me

Uncaught TypeError: Object onBefore(); has no method 'apply'

Arkrep’s picture

StatusFileSize
new25.9 KB

ah .. right you need to put the script into the advanced options box. but without it being wrapped in a function.

Screen

TelFiRE’s picture

Category: bug » support
Priority: Critical » Normal

I really appreciate your attempts to help out, but there is no such option on the current version of Views Slideshow on Drupal 6. There is only "Advanced Options". It is a textarea. There is no dropdown.

It appears you are using Drupal 7. I don't know what's changed. But I wasn't wrapping the function at all in the advanced box and wouldn't expect that to work. The function is created in a document.ready. I mean my understanding is that this advanced options box accepts arguments for the jQuery cycle plugin. So, by all means, the code I've tried should work. If I could just be the one to call cycle, instead of views doing it and screwing with my syntax, this would be cake.

This is an extreme failure in usability of this module in my opinion. :( I really hope someone here can help me out. Is this a bug for me? Because I have run Views Slideshow on probably a dozen or so installations, with separate download/installs and I have never seen that dropdown before.

TelFiRE’s picture

Priority: Normal » Critical
TelFiRE’s picture

Category: support » bug
pelicani’s picture

Category: support » bug
Priority: Normal » Critical

TelFiRE, I haven't tried this yet, but ... http://drupal.org/node/754648
Seems you can set a function on one line for drupal 6 that will let you modify the jquery.

pelicani’s picture

Category: bug » support

I tried that solution I linked to above and it works very well.
I added a function for the 'before' and within it call another function that has more processing logic.
That way I can stick to the 1 line limit within the module function.
I hope this helps.

shaundychko’s picture

Version: 6.x-3.0 » 6.x-2.3
Status: Active » Closed (fixed)

It isn't pretty, but this can be achieved by adding your own code after line 56 of .../views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.js, which is the 'begin' function provided by the module. If someone knows of a way to put this code in a custom module or theme, please leave a note.

TelFiRE’s picture

Category: support » bug
Status: Closed (fixed) » Needs work

That doesn't make any sense to me. This is clearly a bug and NOT working as intended. There is a field for doing exactly what I'm saying and it simply doesn't work. It does not run the code. What is the point of that advanced options box? It NEVER gets called.

redndahead’s picture

Status: Needs work » Postponed (maintainer needs more info)

@TelFiRE it obviously get's called because you get an error. Try different function names than onBefore I think that may be conflicting with another method. Try yomama() or something like that.

redndahead’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing from lack of response.

spideep’s picture

Issue summary: View changes

#8 rocks!