pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

How to prevent autoclose

Fri Mar 02, 2018 12:49 pm

Hi,
I try to stop highslide at the last slide, to constrain user to click on the stop button if he wants to exit.
Is there a way to desactivate autoclose (autoexit) system?
Best regards,
Philippe

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

Re: How to prevent autoclose

Fri Mar 02, 2018 1:26 pm

I assume you're talking about an automated slideshow, where it either loops or automatically closes when it hits the last slide.

If so, there's no built-in way to prevent the automatic close. You have to tinker with the Highslide script itself. I've edited highslide-full.js, and added a slideshow pause in the checkFirstAndLast function, starting at line 3058. So, when it hits the last slide, it pauses the slideshow, and the user must hit Close to exit.

Code: Select all

checkFirstAndLast: function() {
	if (this.repeat || !this.controls) return;
	var exp = hs.expanders[this.expKey],
		cur = exp.getAnchorIndex(), 
		re = /disabled$/;
	if (cur == 0) 
		this.disable('previous');
	else if (re.test(this.btn.previous.getElementsByTagName('a')[0].className))
		this.enable('previous');
	if (cur + 1 == hs.anchors.groups[exp.slideshowGroup || 'none'].length) {
		this.pause(); // Added line
		this.disable('next');
		this.disable('play');
	} else if (re.test(this.btn.next.getElementsByTagName('a')[0].className)) {
		this.enable('next');
		this.enable('play');
	}
},
It seems to work, but no guarantees that this won't screw up something else!

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Fri Mar 02, 2018 6:16 pm

Sorry, I was talking about keyboard navigation. I would stop it at the last slide.
Best regards,
Philippe

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Fri Mar 02, 2018 6:21 pm

I would find a function similar to repeat:true, but without loop.

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

Re: How to prevent autoclose

Fri Mar 02, 2018 6:47 pm

That's going to be very messy. The key handler doesn't include any logic for determining whether it's currently at the first or last slide in the gallery. I'm really not sure it's worth the effort, but I'll come back to it later to see if there's a straightforward way to do it.

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

Re: How to prevent autoclose

Fri Mar 02, 2018 7:28 pm

I may have found an easy way to do this. Only minimally tested, so watch out!

In highslide-full.js, starting at line 2307, replace the entire getAdjacentAnchor function with this:

Code: Select all

getAdjacentAnchor : function(op) {
	var current = this.getAnchorIndex(), as = hs.anchors.groups[this.slideshowGroup || 'none'];
	if (as && !as[current + op] && this.slideshow) return as[current];
	return (as && as[current + op]) || null;
},

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Fri Mar 02, 2018 7:51 pm

It works! This is just what I am waiting for.
Your code solves my problem of switching keyboard navigation between FullPageJs and HighslideJS.
Many thanks.
Philippe

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

Re: How to prevent autoclose

Fri Mar 02, 2018 8:02 pm

Good! :)

Just make sure there is no smoke, and no flames. ;)

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Sat Mar 03, 2018 7:39 am

May I ask if it's now possible to hide next button at the end of the slideshow?
Best regards,
Philippe

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Sat Mar 03, 2018 7:42 am

...to hide or to reduce opacity. The previous button at the beginning of the slideshow too?

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

Re: How to prevent autoclose

Sat Mar 03, 2018 2:23 pm

That happens automatically, as long as the gallery isn't set to loop. See the example here: http://highslide.com/examples/gallery-white.html

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Sat Mar 03, 2018 4:28 pm

No, since we have modified code, this doesn't happen automatically.

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

Re: How to prevent autoclose

Sat Mar 03, 2018 4:52 pm

With only the last modification, it still works. The behavior when trying to right-arrow from the last image isn't ideal (it re-draws the caption, for example), but at least it doesn't close the expander. And the previous and next arrows are dimmed out when they should be:

(demo page removed)

Somewhat off-topic, but I gather that you're new to Highslide JS, and you're incorporating it into a site for the first time. This may not be a wise choice. Highslide JS is "abandonware," with no development and no support (it looks like I'm the only one in the entire world who's doing any support, and I'm not really a Javascript guy). The script is obsolete in a lot of ways, and its flaws are never going to be fixed. I really can't recommend it for new development.

In particular, trying to use it for a truly responsive, "desktop to smartphone" site produces a number of nasty surprises. It's also not responsive at all for anything other than images. HTML expanders, including those for things like videos, do not respond to the size of the viewport, and there's no easy way to modify the script to do that.
Last edited by MisterNeutron on Sat Mar 03, 2018 5:08 pm, edited 1 time in total.

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Sat Mar 03, 2018 5:06 pm

Yes, I am new to Highslide JS, but it responds quite to my project. The slides are only images.
About the reduction of opacity, sorry, its works: I forgot to configure repeat:false.
Many thanks for all!
Best regards,
Philippe

pchantelou
Posts: 10
Joined: Fri Mar 02, 2018 11:08 am

Re: How to prevent autoclose

Sun Mar 04, 2018 10:04 am

May I ask a last question?
How to prevent to close when we click on the img.highslide-image.
I have got it with the dimmer background setuping it in pause in highslide-full.js, but not with the img
Best regards,
Philippe

Return to “Highslide JS Usage”