swess
Posts: 4
Joined: Mon Oct 30, 2017 3:10 pm

different hs.expandDuration for picture and for slideshow

Mon Oct 30, 2017 3:50 pm

I have two objects on one page - it's a slideshow and just a picture
How to make different expandDuration for picture and for slideshow?


Code: Select all

hs.expandDuration = 1000; // work for the picture

hs.addSlideshow({
     slideshowGroup: 'group1',
     interval: 5000,
     repeat: true,
     expandDuration: 20, //don't work  for slideshow
     useControls: false,
	 relativeTo: 'expander',
     overlayOptions: {
         position: 'bottom left',
         offsetY: 50
     },
     thumbstrip: {
         position: 'below',
         mode: 'horizontal',
         relativeTo: 'expander'
     }
 });

MisterNeutron
Posts: 430
Joined: Sun Aug 18, 2013 11:20 am

Re: different hs.expandDuration for picture and for slidesho

Mon Oct 30, 2017 8:03 pm

The short answer is that you can't. That attribute is not part of the addSlideshow stuff, in which you can define different groups of images. It's a "one setting for the entire page" attribute, and per the API, it can't be overridden inline, either.

swess
Posts: 4
Joined: Mon Oct 30, 2017 3:10 pm

Re: different hs.expandDuration for picture and for slidesho

Mon Oct 30, 2017 9:39 pm

it's very strange - are you sure that this is definitely impossible to change? maybe there are some non-obvious ways?
for example, something

Code: Select all

if (hs.addSlideshow) {
this.expandDuration = 250;
}

OR
var config1 = {
	expandDuration: 1000,
};
Well, at least something? at least some option?

MisterNeutron
Posts: 430
Joined: Sun Aug 18, 2013 11:20 am

Re: different hs.expandDuration for picture and for slidesho

Mon Oct 30, 2017 10:26 pm

Just took a look at the Highslide JS source code. Very sure. You'd have to modify the script to make that possible.

I took a shot at hacking the code, and actually got it working, mirabile dictu. But before posting anything, I'm guessing you'd also like to change the restoreDuration too, right?

swess
Posts: 4
Joined: Mon Oct 30, 2017 3:10 pm

Re: different hs.expandDuration for picture and for slidesho

Mon Oct 30, 2017 10:37 pm

In general, I initially needed only expandDuration, but if you know how to change restoreDuration it is doubly remarkable. I would like to see how you changed the source

MisterNeutron
Posts: 430
Joined: Sun Aug 18, 2013 11:20 am

Re: different hs.expandDuration for picture and for slidesho

Mon Oct 30, 2017 11:07 pm

OK, here's a quickly-slapped-together demo: https://misterneutron.com/HSdiffexp

In short, I've managed to make it possible to override expandDuration and restoreDuration inline. Take a look at the page source code, and it should be obvious how I've applied it to the images in the first group. You could, of course, do this with config objects, but for a single image, it's simpler to put the stuff inline.

The hacked script is hsdiffexp.js (it's at the root of the page, so easy to grab). I added those two variables to the overrides variable (at line 194). Then, from that point and below, I replaced every occurrence of hs.expandDuration with this.expandDuration. Ditto for restoreDuration.

I have no idea if this will break something else, but at least in the simple demo case, it appears to work as advertised.

swess
Posts: 4
Joined: Mon Oct 30, 2017 3:10 pm

Re: different hs.expandDuration for picture and for slidesho

Tue Oct 31, 2017 8:07 am

Great Job! Thank you! It's work beautiful!

Return to “Highslide JS Usage”