Skip to content

Instantly share code, notes, and snippets.

@onebytegone
Last active March 2, 2018 20:11
Show Gist options
  • Save onebytegone/941cb2a3128b474a63908b86b522dff6 to your computer and use it in GitHub Desktop.
Save onebytegone/941cb2a3128b474a63908b86b522dff6 to your computer and use it in GitHub Desktop.
Demo of conflict between jQuery and webcomponent.js in Chromecast framework
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Demo of conflict between jQuery and webcomponent.js in Chromecast framework</title>
<script>
window.SILVERMINE_VIDEOJS_CHROMECAST_CONFIG = {
preloadWebComponents: true,
};
</script>
<script src="../../dist/silvermine-videojs-chromecast.min.js"></script>
<link href="../../dist/silvermine-videojs-chromecast.css" rel="stylesheet">
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
<script src="https://unpkg.com/[email protected]/dist/jquery.js"></script>
<style>
.boxWrapper {
position: relative;
height: 40px;
width: 20px;
border: 1px solid black;
}
#box {
position: absolute;
top: 20px;
width: 20px;
height: 20px;
background-color: skyblue;
}
</style>
</head>
<body>
<h1>Demo of conflict between jQuery and <code>webcomponents.js</code></h1>
<h2>Moving box</h2>
<p>This box will move on iOS Safari, but not on Chrome.</p>
<div class="boxWrapper">
<div id="box"></div>
</div>
<h2>Video</h2>
<video controls src="http://www.caminandes.com/download/03_caminandes_llamigos_1080p.mp4" type="video/mp4" style="width: 100%;"></video>
<script>
$(document).ready(function() {
setTimeout(function() {
var el = $('#box'),
moveEl, moveUp, moveDown;
moveEl = function(pos, done) {
try {
el.animate({
top: pos
}, 400, done);
} catch(e) {
alert(e);
}
};
moveDown = function() {
moveEl(20, moveUp);
};
moveUp = function() {
moveEl(0, moveDown);
};
moveUp();
}, 1000);
});
</script>
</body>
</html>
@onebytegone
Copy link
Author

onebytegone commented Mar 2, 2018

Differences between revisions:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment