Skip to content

Instantly share code, notes, and snippets.

@samueleastdev
Created December 19, 2018 22:19
Show Gist options
  • Save samueleastdev/0164bcf1f50a80d9909ebed62e245bc2 to your computer and use it in GitHub Desktop.
Save samueleastdev/0164bcf1f50a80d9909ebed62e245bc2 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/juzanuz
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" type="text/css" href="https://kenwheeler.github.io/slick/slick/slick.css"/>
<link rel="stylesheet" type="text/css" href="https://kenwheeler.github.io/slick/slick/slick-theme.css"/>
<style id="jsbin-css">
.movies {
margin: 0;
padding: 0;
}
.slick-active.next-tiles {
transform-origin: top left;
transform: scaleX(1) translateX(220%) !important;
}
.slick-active.prev-tiles {
transform-origin: top right;
transform: scaleX(1) translateX(-220%) !important;
}
.portrait {
transform-origin: top left;
background: #ddd;
position: relative;
overflox: hidden;
}
.portrait video {
transform-origin: top left;
width: 100%;
height:100%;
position: absolute;
top: 0;
}
/* SPACING BETWEEN TILES:: */
.slick-slide {
margin: 0 2px;
}
.slick-list {
margin: 0 -2px;
}
</style>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://kenwheeler.github.io/slick/slick/slick.js"></script>
<div class="movies">
<div class="portrait" data-ind='1'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait" data-ind='2'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WhatCarCanYouGetForAGrand.mp4" type="video/mp4">
</video>
</div>
<div class="portrait" data-ind='3'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4" type="video/mp4">
</video>
</div>
<div class="portrait" data-ind='4'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4" type="video/mp4">
</video>
</div>
<div class="portrait" data-ind='5'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4" type="video/mp4">
</video>
</div>
<div class="portrait" data-ind='6'>
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
<div class="portrait">
<video id="video" webkit-playsinline="true" playsinline="true" poster="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
</div>
</div>
<script id="jsbin-javascript">
var count = 6;
var mtile = Math.round($('.movies').width() / count);
var portHeight = mtile;
var port169 = Math.round(portHeight / 9 * 16);
$('.portrait').width(portHeight);
$('.portrait').height(port169);
$('.movies').height(port169);
$('.portrait').bind({
mouseenter: function() {
var vwidth = $(this).height() / 9 * 16;
var scaleX = Math.min(vwidth / portHeight);
var index = parseInt($(this).data('ind'));
if (index <= 3) {
$(this).css('transform-origin', 'top left');
$(this).nextAll("div").addClass("next-tiles");
} else {
$(this).css('transform-origin', 'top right');
$(this).prevAll("div").addClass("prev-tiles");
}
$(this).css('transform', 'scaleX(' + scaleX + ')');
$(this).find('video').height(port169);
$(this).find('video').width(vwidth);
$(this).find('video').css('transform', 'scaleX(' + (1 / scaleX) + ')');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).controls = true;
video.get(0).play();
},
mouseleave: function() {
$(this).prevAll("div").removeClass("prev-tiles");
$(this).nextAll("div").removeClass("next-tiles");
$(this).css('transform', 'scaleX(1)');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).pause();
}
});
$('.movies').slick({
infinite: true,
slidesToShow: count,
slidesToScroll: 1,
dots: true,
});
</script>
<script id="jsbin-source-css" type="text/css">.movies {
margin: 0;
padding: 0;
}
.slick-active.next-tiles {
transform-origin: top left;
transform: scaleX(1) translateX(220%) !important;
}
.slick-active.prev-tiles {
transform-origin: top right;
transform: scaleX(1) translateX(-220%) !important;
}
.portrait {
transform-origin: top left;
background: #ddd;
position: relative;
overflox: hidden;
}
.portrait video {
transform-origin: top left;
width: 100%;
height:100%;
position: absolute;
top: 0;
}
/* SPACING BETWEEN TILES:: */
.slick-slide {
margin: 0 2px;
}
.slick-list {
margin: 0 -2px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var count = 6;
var mtile = Math.round($('.movies').width() / count);
var portHeight = mtile;
var port169 = Math.round(portHeight / 9 * 16);
$('.portrait').width(portHeight);
$('.portrait').height(port169);
$('.movies').height(port169);
$('.portrait').bind({
mouseenter: function() {
var vwidth = $(this).height() / 9 * 16;
var scaleX = Math.min(vwidth / portHeight);
var index = parseInt($(this).data('ind'));
if (index <= 3) {
$(this).css('transform-origin', 'top left');
$(this).nextAll("div").addClass("next-tiles");
} else {
$(this).css('transform-origin', 'top right');
$(this).prevAll("div").addClass("prev-tiles");
}
$(this).css('transform', 'scaleX(' + scaleX + ')');
$(this).find('video').height(port169);
$(this).find('video').width(vwidth);
$(this).find('video').css('transform', 'scaleX(' + (1 / scaleX) + ')');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).controls = true;
video.get(0).play();
},
mouseleave: function() {
$(this).prevAll("div").removeClass("prev-tiles");
$(this).nextAll("div").removeClass("next-tiles");
$(this).css('transform', 'scaleX(1)');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).pause();
}
});
$('.movies').slick({
infinite: true,
slidesToShow: count,
slidesToScroll: 1,
dots: true,
});</script></body>
</html>
.movies {
margin: 0;
padding: 0;
}
.slick-active.next-tiles {
transform-origin: top left;
transform: scaleX(1) translateX(220%) !important;
}
.slick-active.prev-tiles {
transform-origin: top right;
transform: scaleX(1) translateX(-220%) !important;
}
.portrait {
transform-origin: top left;
background: #ddd;
position: relative;
overflox: hidden;
}
.portrait video {
transform-origin: top left;
width: 100%;
height:100%;
position: absolute;
top: 0;
}
/* SPACING BETWEEN TILES:: */
.slick-slide {
margin: 0 2px;
}
.slick-list {
margin: 0 -2px;
}
var count = 6;
var mtile = Math.round($('.movies').width() / count);
var portHeight = mtile;
var port169 = Math.round(portHeight / 9 * 16);
$('.portrait').width(portHeight);
$('.portrait').height(port169);
$('.movies').height(port169);
$('.portrait').bind({
mouseenter: function() {
var vwidth = $(this).height() / 9 * 16;
var scaleX = Math.min(vwidth / portHeight);
var index = parseInt($(this).data('ind'));
if (index <= 3) {
$(this).css('transform-origin', 'top left');
$(this).nextAll("div").addClass("next-tiles");
} else {
$(this).css('transform-origin', 'top right');
$(this).prevAll("div").addClass("prev-tiles");
}
$(this).css('transform', 'scaleX(' + scaleX + ')');
$(this).find('video').height(port169);
$(this).find('video').width(vwidth);
$(this).find('video').css('transform', 'scaleX(' + (1 / scaleX) + ')');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).controls = true;
video.get(0).play();
},
mouseleave: function() {
$(this).prevAll("div").removeClass("prev-tiles");
$(this).nextAll("div").removeClass("next-tiles");
$(this).css('transform', 'scaleX(1)');
var video = $(this).find('video');
video.get(0).muted = true;
video.get(0).pause();
}
});
$('.movies').slick({
infinite: true,
slidesToShow: count,
slidesToScroll: 1,
dots: true,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment