简体   繁体   English

超大尺寸全屏滑块API

[英]Supersized Full Screen Slider API

http://buildinternet.com/project/supersized/ http://buildinternet.com/project/supersized/

I'm having trouble figuring out the javascript that goes along with this jquery plugin. 我在弄清楚与此jquery插件一起使用的javascript时遇到了麻烦。 What I'm trying to do is merge this with more js plugins, namely, an accordion plugin I have. 我正在尝试将其与更多js插件(即我拥有的手风琴插件)合并。 The end goal is to essentially have two instances of Supersized running on one screen with the same controls, different images. 最终目标是实质上在一个屏幕上运行两个具有相同控件,不同图像的Supersized实例。 I know, hard to envision but here's an example. 我知道,很难想象,但这是一个例子。

The body is full screen background with Supersized, the image is image1.jpg and it's black and white. 主体是具有Supersized的全屏背景,图像是image1.jpg,并且是黑白的。 Then, I have a smaller div, 960px wide in the center of the body, with an accordion of all the images I want, but in color. 然后,我在主体中心有一个较小的div,宽度为960px,上面放着我想要的所有图像的手风琴,但是是彩色的。 So as you change the accordion, you change the background. 因此,当您更改手风琴时,就更改了背景。 So when you have image1.jpg in color in the accordion box, the background of body is image1.jpg black and white. 因此,当手风琴盒中的颜色为image1.jpg时,主体的背景为黑白的image1.jpg。

So I'm having trouble because the js for supersized seems to only define a prev and next thumbnail, not ALL the thumbnails. 因此,我遇到了麻烦,因为用于超大尺寸的js似乎仅定义了上一个和下一个缩略图,而不是所有缩略图。 So in theory I would have to figure out how to disoplay all thumbnails and then figure out how to alter these thumbnails' images so that it is still controlling the slide transitions, but not actually the thumbnails for the background. 因此,从理论上讲,我将必须弄清楚如何取消播放所有缩略图,然后弄清楚如何更改这些缩略图的图像,以便它仍控制幻灯片过渡,但实际上不控制背景的缩略图。 In that way, I can then set the accordion slides to those thumbnails instead but have them control both the accordion and the background. 这样,我就可以将手风琴幻灯片设置为这些缩略图,但是让它们控制手风琴和背景。

I'm sure I'm being very confusing right now, so if you have any questions, ask away. 我确定我现在很困惑,所以如果您有任何疑问,请问。 Thanks. 谢谢。

Lets see if i got your question right, 让我们看看我是否正确回答了您的问题,

if you're looking for a way to change the background image (used by supersized) on clicking on a div or something, then there are many ways to do it. 如果您正在寻找一种方法来单击div或其他内容来更改背景图像(供超大尺寸使用),那么有很多方法可以实现。

The following code may help you out, it will replace the active slide image name with a '-bw' in the end of it. 以下代码可能会对您有所帮助,它将结尾的活动幻灯片图像名称替换为“ -bw”。

for example : clicking on a div with a class name 'click-me' will change the background image from 'image.jpg' to 'image-bw.jpg' 例如:单击类名称为“ click-me”的div会将背景图像从“ image.jpg”更改为“ image-bw.jpg”

function changeBg() {
  var $supersizedImg = $("#supersized .activeslide img"),
      imgSrc = $supersizedImg.attr('src');
  imgSrcArray = imgSrc.split('/'); //split the image source by '/'
  fullFileName = imgSrcArray[imgSrcArray.length - 1]; //get the file name
  fileName = fullFileName.split('.'); //split that file name by '.'
  fileName[0] = fileName[0] + '-bw'; //grab the first array element(which is filename without extension and add a '-bw' in the end)
  fileName = fileName.join('.'); //join the new file name with its extension with a '.'
  imgSrcArray[imgSrcArray.length - 1] = fileName; //add the new file name the the last element of imgSrcArray. 
  imgSrcArray = imgSrcArray.join('/'); //join the whole url by '/'
  $supersizedImg.attr('src', imgSrcArray); //add the new url to the img src of supersized
}

$('.click-me').on('click', changeBg); //call changeBg function when a div is clicked

hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM