内容简介:轮播中显示的视频组组件.例如,我的代码可能看起来像自定义元素:但是,我不想仅仅在iframe中显示每个视频,而是希望这些视频出现在由Slick提供支持的旋转木马中,所以我想要做一些与以下相关的事情:
轮播中显示的视频组组件.
例如,我的代码可能看起来像自定义元素:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymer-jsonp/polymer-jsonp.html">
<polymer-element name="polymer-video-group" constructor="VideoGroupElement" attributes="">
<template>
<style>
/* styles for the custom element itself - lowest specificity */
:host {
display: block;
position: relative;
}
/*
style if an ancestor has the different class
:host(.different) { }
*/
</style>
<!-- Load Data with JSONP Endpoint (in this case Google Spreadsheets)
Source: https://docs.google.com/spreadsheet/ccc?key=0AqZBbhllhMtHdFhFYnRlZk1zMzVZZU5WRnpLbzFYVFE&usp=sharing
https://docs.google.com/spreadsheets/d/1CpXbJHeFrzPpg58lWAsT1N3-QExbX9T5OPVeMfyBqYs/pubhtml
-->
<polymer-jsonp id="jsonp" url="https://spreadsheets.google.com/feeds/list/1CpXbJHeFrzPpg58lWAsT1N3-QExbX9T5OPVeMfyBqYs/od6/public/values?alt=json-in-script&callback=" response="{{response}}"></polymer-jsonp>
<template repeat="{{entry in response.feed.entry}}">
<iframe width="420" height="315" src="//www.youtube.com/embed/{{entry.gsx$id.$t}}" frameborder="0" allowfullscreen></iframe>
</template>
</template>
<script>
Polymer('polymer-video-group', {
// element is fully prepared
ready: function(){
this.$.jsonp.go();
},
// instance of the element is created
created: function() {
this.videos = [];
this.response = {};
},
// instance was inserted into the document
enteredView: function() { },
// instance was removed from the document
leftView: function() { },
// attribute added, removed or updated
attributeChanged: function(attrName, oldVal, newVal) { },
// Response from JSONP Data Changed Event Handler
responseChanged: function() {
// Get the Entry Point for the JSON Feed
var entries = this.response.feed.entry;
// Create an empty variable to store the video group
var videos = [];
// Push entries from the JSON feed onto the videos array
for (var i = 0, entry; entry = entries[i]; ++i) {
videos.push({
name: entry.gsx$name.$t,
id: entry.gsx$id.$t
});
}
// Set the video group object's array to this newly supplied video array
this.videos = videos;
}
});
</script>
</polymer-element>
但是,我不想仅仅在iframe中显示每个视频,而是希望这些视频出现在由Slick提供支持的旋转木马中,所以我想要做一些与以下相关的事情:
<link rel="import" href="../bower_components/polymer/polymer.html"> <link rel="import" href="../bower_components/polymer-jsonp/polymer-jsonp.html"> <script src="../bower_components/slick-carousel/slick/slick.js"></script>
我是否必须创建一个包含光滑功能的自定义元素,还是可以直接使用上述示例中的资源?
更新:
我创建了一个“elements / slick-import.html”文件,其中包含Slick需要的3件事:
<link rel="stylesheet" href="../bower_components/slick-carousel/slick/slick.css"/> <script src="../bower_components/jquery/dist/jquery.js"></script> <script src="../bower_components/slick-carousel/slick/slick.js"></script>
在我的elements / video-group.html元素中,我将其引用为:
…
…
我注意到该页面包含slick.css文件,但是当页面加载时,Slick所需的其他2个js文件没有附加到DOM.我是否在slick-import.html中正确引用了包含的脚本?
更新2:
这是我真正的问题:我有这个重复模板打印出我从jsonp响应构建的视频列表:
<div id="carousel">
<template repeat="{{video in videos}}">
<div>
<iframe width="420" height="315" src="//www.youtube.com/embed/{{video.id}}" frameborder="0" allowfullscreen></iframe>
</div>
</template>
</div>
但是,最糟糕的是Chrome DevTools中生成的DOM显示了这样的标记:
<video-group>
<div id="carousel" class="slick-initialized slick-slider">
<template repeat="{{video in videos}}"></template>
<div>
<iframe width="420" height="315" src="//www.youtube.com/embed/Fp1wPwszF9M" frameborder="0" allowfullscreen=""></iframe>
</div>
<div>
<iframe width="420" height="315" src="//www.youtube.com/embed/H-l2cq-MXUs" frameborder="0" allowfullscreen=""></iframe>
</div>
<div class="slick-list draggable" tabindex="0" style="padding: 0px 50px;">
<div class="slick-track" style="width: 0px; -webkit-transform: translate3d(-832px, 0px, 0px); opacity: 1;"></div>
</div>
</div>
<!-- Load Data with JSONP Endpoint (in this case Google Spreadsheets)
Source: https://docs.google.com/spreadsheet/ccc?key=0AqZBbhllhMtHdFhFYnRlZk1zMzVZZU5WRnpLbzFYVFE&usp=sharing
https://docs.google.com/spreadsheets/d/1CpXbJHeFrzPpg58lWAsT1N3-QExbX9T5OPVeMfyBqYs/pubhtml
-->
<polymer-jsonp id="jsonp" url="https://spreadsheets.google.com/feeds/list/1CpXbJHeFrzPpg58lWAsT1N3-QExbX9T5OPVeMfyBqYs/od6/public/values?alt=json-in-script&callback=" response="{{response}}"></polymer-jsonp>
</video-group>
注意div#carousel有一类“slick-initialized”和“slick-slider”.这意味着我的Slick Carousel正确地作用于我的div#carousel DOM元素,但由于嵌套在下面的挥之不去的模板标签,这使得Slick从一些漂亮干净的简单DIV上行动起来,就像 Slick docs 演示中的示例一样:
<div class="your-class"> <div>your content</div> <div>your content</div> <div>your content</div> </div>
无论如何我可以通过特定于聚合物的方法解决这个问题,或者以某种方式修改Slick以仅定位div #carousel下面的子div?
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- UGUI研究院之一个脚本同时裁切UI元素和粒子特效和3D模型(三十一)
- CSS 基础:块级元素、行内元素、替换元素、非替换元素
- CSS 技巧篇(六):display设置元素为行内元素时,元素之间存在间隙问题
- 探究行内元素和块级元素
- 重学前端:块级元素与内联元素
- 使CSS伪元素:在与主元素相同的高度之前
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Graph Theory
Douglas B. West / Prentice Hall / 2000-9-1 / USD 140.00
For undergraduate or graduate courses in Graph Theory in departments of mathematics or computer science. This text offers a comprehensive and coherent introduction to the fundamental topics of graph ......一起来看看 《Introduction to Graph Theory》 这本书的介绍吧!
图片转BASE64编码
在线图片转Base64编码工具
正则表达式在线测试
正则表达式在线测试