").appendTo(i);if(r.pagination==true){e(".is-pagination li a").click(function(){var t=e(this).attr("href");if(!e(this).hasClass("active")){i.moveSlider(r,t)}return false})}e(".is-next").click(function(){i.moveNext();return false});e(".is-prev").click(function(){i.movePrev();return false});e.fn.moveSlider=function(t,n){var r=e(this),i=r.find(".is-slide.active"),s=r.find(".is-slide"+n),o=e(t.container).find(".is-background.active"),u=e(t.container).find(".is-background"+n+"_bg");if(s){i.removeClass("active");s.addClass("active");o.removeClass("active");u.addClass("active");e(".is-pagination li a"+".active").removeClass("active");e(".is-pagination li a"+"[href='"+n+"']").addClass("active")}pos=(n.replace("#slide_","")-1)*100*-1;r.find(".is-overflow").transformSlider(t,pos);e(t.container).find(".is-bg-overflow").transformSlider(t,pos)};e.fn.moveNext=function(){var t=e(this),n=t.find(r.slideSelector).length+1,i=parseInt(e(this).find(".is-slide.active").attr("id").replace("slide_",""))+1;if(i0){t.moveSlider(r,"#slide_"+i)}else{if(r.loop==true)t.moveSlider(r,"#slide_"+(n-1))}};i.swipeEvents().bind("swipeRight",function(){i.movePrev()}).bind("swipeLeft",function(){i.moveNext()})}}(window.jQuery)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Immersive Slider by Pete R.
2 | Create an immersive slider that changes the whole container to match the viewing slide
3 | Created by [Pete R.](http://www.thepetedesign.com), Founder of [BucketListly](http://www.bucketlistly.com)
4 |
5 |
6 | ## Demo
7 | [View demo](http://peachananr.github.io/immersive-slider/Demo/demo.html)
8 |
9 | ## Compatibility
10 | Modern browsers such as Chrome, Firefox, and Safari on both desktop and smartphones have been tested. Not tested on IE.
11 |
12 | ## Basic Usage
13 | Immersive Slider let you create a unique immersive slider experience that changes the whole container to match the viewing slide like you see at the [Google's TV website](http://www.google.com/tv/). The plugin will let you assign background images per slide without you doing all the hard work.
14 |
15 | To add this to your website, simply include the latest jQuery library together with `jquery.immersive-slider.js`, and `immersive-slider.css` into your document's `` and create an HTML markup as follows:
16 |
17 | ````html
18 |
34 | ````
35 | The container main will be used to display the background images. Make sure you change all the `<>` occurrences to the image path you wish the slider to show when that slide is active. Feel free to remove the navigational buttons if you don't need it. Once that is done, simply call the script like this:
36 |
37 | ````javascript
38 | $("#immersive_slider").immersive_slider({
39 | animation: "bounce", // As usual, you can change the animation to these: slide (default), bounce, fade, slideUp, and bounceUp
40 | slideSelector: ".slide", // This option will let you assign custom selector for each slides in case .slide is already taken
41 | container: ".main", // This option lets you define the container of which the background will appear. Make sure the slider is inside this container as well.
42 | cssBlur: false, // Experimental: In case you don't want to keep adding new data-blurred attributes, trigger this to true and it will generate the blur image on the fly (more info below).
43 | pagination: true, // Toggle this to false if you don't want a pagination
44 | loop: true, // Toggle to false if you don't want the slider to loop. Default is true.
45 | autoStart: 5000 // Define the number of milliseconds before it navigates automatically. Change this to 0 or false to disable autoStart. The default value is 5000.
46 | });
47 | ````
48 | And that's all you have to do to get this plugin up and running on your website. Pretty easy right?
49 |
50 | ## Experimental Feature: CSSBlur
51 | The plugin is capable of blurring the first image it finds in each slide, blow them up and use it as a background without you having to manually set each slide a background image. This is done using the CSS3 style called Filter which only works on Chrome, and maybe a performance hog. Use it at your own risk.
52 |
53 | To do this simply toggle the cssBlur option to true like this:
54 |
55 | ````javascript
56 | $("#immersive_slider").immersive_slider({
57 | cssBlur: true
58 | });
59 | ````
60 |
61 | and make sure the images you want to blow up as a background are in each slides like this:
62 |
63 | ````html
64 |
65 | ...
66 |
67 |
68 |
69 | ...
70 |
71 |
72 |
73 | ...
74 |
75 | ...
76 |
77 |
78 | ````
79 |
80 | The script will grab this first image, apply the CSS filter and blow them up with CSS filling the container for you. This is great when you already have an existing slider and you don't want to add a new attribute for the background.
81 |
82 | ## Public Methods
83 | You can also trigger the slider to move programmatically as well:
84 |
85 | ### $.fn.moveNext()
86 | This method allows you to move the slider to the next one.
87 |
88 | ````javascript
89 | $("#immersive_slider").moveNext();
90 | ````
91 |
92 | ### $.fn.movePrev()
93 | This method allows you to move the slider to the previous one.
94 |
95 | ````javascript
96 | $("#immersive_slider").movePrev();
97 | ````
98 |
99 | If you want to see more of my plugins, visit [The Pete Design](http://www.thepetedesign.com/#design), or follow me on [Twitter](http://www.twitter.com/peachananr) and [Github](http://www.github.com/peachananr).
100 |
101 | ## Other Resources
102 | - Tutorial (Coming Soon)
103 | - [Eike Send's jQuery Swipe Events](https://github.com/eikes/jquery.swipe-events.js)
104 |
--------------------------------------------------------------------------------
/jquery.immersive-slider.js:
--------------------------------------------------------------------------------
1 | /* ===========================================================
2 | * jquery-immersive-slider.js v1
3 | * ===========================================================
4 | * Copyright 2013 Pete Rojwongsuriya.
5 | * http://www.thepetedesign.com
6 | *
7 | * Create an immersive slider that changes the
8 | * the whole container to match the viewing slide
9 | *
10 | * https://github.com/peachananr/immersive-slider
11 | *
12 | * ========================================================== */
13 |
14 | !function($){
15 |
16 | var defaults = {
17 | animation: "bounce",
18 | slideSelector: ".slide",
19 | container: ".main",
20 | cssBlur: false,
21 | pagination: true,
22 | loop: true,
23 | autoStart: 4000
24 | };
25 |
26 | /*------------------------------------------------*/
27 | /* Credit: Eike Send for the awesome swipe event */
28 | /*------------------------------------------------*/
29 |
30 | $.fn.swipeEvents = function() {
31 | return this.each(function() {
32 |
33 | var startX,
34 | startY,
35 | $this = $(this);
36 |
37 | $this.bind('touchstart', touchstart);
38 |
39 | function touchstart(event) {
40 | var touches = event.originalEvent.touches;
41 | if (touches && touches.length) {
42 | startX = touches[0].pageX;
43 | startY = touches[0].pageY;
44 | $this.bind('touchmove', touchmove);
45 | }
46 | event.preventDefault();
47 | }
48 |
49 | function touchmove(event) {
50 | var touches = event.originalEvent.touches;
51 | if (touches && touches.length) {
52 | var deltaX = startX - touches[0].pageX;
53 | var deltaY = startY - touches[0].pageY;
54 |
55 | if (deltaX >= 50) {
56 | $this.trigger("swipeLeft");
57 | }
58 | if (deltaX <= -50) {
59 | $this.trigger("swipeRight");
60 | }
61 | if (deltaY >= 50) {
62 | $this.trigger("swipeUp");
63 | }
64 | if (deltaY <= -50) {
65 | $this.trigger("swipeDown");
66 | }
67 | if (Math.abs(deltaX) >= 50 || Math.abs(deltaY) >= 50) {
68 | $this.unbind('touchmove', touchmove);
69 | }
70 | }
71 | event.preventDefault();
72 | }
73 |
74 | });
75 | };
76 |
77 | $.fn.transformSlider = function(settings, pos) {
78 | var el = $(this)
79 | switch(settings.animation) {
80 | case 'slide':
81 | el.addClass("ease").css({
82 | "-webkit-transform": "translate3d(" + pos + "%, 0, 0)",
83 | "-moz-transform": "translate3d(" + pos + "%, 0, 0)",
84 | "-ms-transform": "translate3d(" + pos + "%, 0, 0)",
85 | "transform": "translate3d(" + pos + "%, 0, 0)"
86 | });
87 | break;
88 | case 'slideUp':
89 | el.addClass("ease").css({
90 | "-webkit-transform": "translate3d(0, " + pos + "%, 0)",
91 | "-moz-transform": "translate3d(0, " + pos + "%, 0)",
92 | "-ms-transform": "translate3d(0, " + pos + "%, 0)",
93 | "transform": "translate3d(0, " + pos + "%, 0)"
94 | });
95 | break;
96 | case 'bounce':
97 | el.addClass("bounce").css({
98 | "-webkit-transform": "translate3d(" + pos + "%, 0, 0)",
99 | "-moz-transform": "translate3d(" + pos + "%, 0, 0)",
100 | "-ms-transform": "translate3d(" + pos + "%, 0, 0)",
101 | "transform": "translate3d(" + pos + "%, 0, 0)"
102 | });
103 | break;
104 | case 'bounceUp':
105 | el.addClass("bounce").css({
106 | "-webkit-transform": "translate3d(0, " + pos + "%, 0)",
107 | "-moz-transform": "translate3d(0, " + pos + "%, 0)",
108 | "-ms-transform": "translate3d(0, " + pos + "%, 0)",
109 | "transform": "translate3d(0, " + pos + "%, 0)"
110 | });
111 | break;
112 | case 'fade':
113 | el.addClass("no-animation").fadeOut("slow", function() {
114 | el.css({
115 | "-webkit-transform": "translate3d(" + pos + "%, 0, 0)",
116 | "-moz-transform": "translate3d(" + pos + "%, 0, 0)",
117 | "-ms-transform": "translate3d(" + pos + "%, 0, 0)",
118 | "transform": "translate3d(" + pos + "%, 0, 0)"
119 | }).fadeIn("slow");
120 | });
121 |
122 | break;
123 | }
124 | }
125 |
126 | $.fn.positionSlides = function(settings, index) {
127 | var el = $(this);
128 | if (settings.animation == "slideUp" || settings.animation == "bounceUp") {
129 | el.css({
130 | top: (index * 100) + "%"
131 | });
132 | }else {
133 | el.css({
134 | left: (index * 100) + "%"
135 | });
136 | }
137 | }
138 |
139 |
140 |
141 | $.fn.immersive_slider = function(options){
142 | var settings = $.extend({}, defaults, options),
143 | el = $(this),
144 | cssblur = "",
145 | pagination = "";
146 |
147 | // Add all the gs sepecific classes
148 | el.addClass("immersive_slider")
149 | el.find(settings.slideSelector).addClass("is-slide");
150 |
151 | // Use CSS to blur the first image the plugin found automatically
152 | if (settings.cssBlur == true) {
153 | el.find(".is-slide img:first-child").each(function( index ) {
154 | var activeclass = ""
155 | if(index == 0) activeclass = "active"
156 | var img = $(this);
157 |
158 | $(settings.container).addClass("is-container").prepend("
It’s never been easier to watch YouTube on the big screen
490 | Send your favorite YouTube videos from your Android phone or tablet to TV with the touch of a button. It’s easy. No wires, no setup, no nothing. Find out more here.
It’s never been easier to watch YouTube on the big screen
502 | Send your favorite YouTube videos from your Android phone or tablet to TV with the touch of a button. It’s easy. No wires, no setup, no nothing. Find out more here.
It’s never been easier to watch YouTube on the big screen
512 | Send your favorite YouTube videos from your Android phone or tablet to TV with the touch of a button. It’s easy. No wires, no setup, no nothing. Find out more here.