【发布时间】:2016-06-16 14:56:41
【问题描述】:
我不知道这个问题是否属于Angular2。但我正在使用 Angular2 并希望使用 HTML、CSS 和 JS 集成 this demo shown here - (please check its working demo and animated content)。此演示展示了带有动画内部内容的 bootstrap 轮播。
This is my Demo in Plunker with Angular2。我已经尝试集成它,一切正常,除了我看不到轮播内部内容的动画,如文章所示。
另外请指导如何在Angular2中使用jQuery和其他JS库?
index.html
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2.dev.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<!-- Demo scripts -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<!-- Animate.css library -->
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/demo.css" rel="stylesheet">
<script src="js/demo.js"></script>
demo.js
/* Demo Scripts for Bootstrap Carousel and Animate.css article
* on SitePoint by Maria Antonietta Perna
*/
(function( $ ) {
//Function to animate slider captions
function doAnimations( elems ) {
//Cache the animationend event in a variable
var animEndEv = 'webkitAnimationEnd animationend';
elems.each(function () {
var $this = $(this),
$animationType = $this.data('animation');
$this.addClass($animationType).one(animEndEv, function () {
$this.removeClass($animationType);
});
});
}
//Variables on page load
var $myCarousel = $('#carousel-example-generic'),
$firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']");
//Initialize carousel
$myCarousel.carousel();
//Animate captions in first slide on page load
doAnimations($firstAnimatingElems);
//Pause carousel
$myCarousel.carousel('pause');
//Other slides to be animated on carousel slide event
$myCarousel.on('slide.bs.carousel', function (e) {
var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']");
doAnimations($animatingElems);
});
})(jQuery);
如何在Angular2应用程序中使用这个包含jQuery代码的demo.js?
【问题讨论】:
-
不,不是那样的。我遵循了文章所说的内容。一切正常。但问题是我看不到文章中显示的动画内部内容。所以想不通。 Angular2 有什么需要做的,或者只是缺少一些我无法弄清楚的东西。
-
没有 angular2 它可以工作并且没有任何问题。我有 anuglar2 应用程序并想要实施。而已。但它不起作用。
-
如果您阅读了我的问题。我已经明确提到我不知道它是否属于angular2。但问题是我想在 angular2 应用程序中使用它。使用 angular2 应用程序它不起作用。我提供了 plunker 或我的工作。你可以检查一下。一切正常。只有我想拥有不工作的轮播动画内容。该文章使用
animation.css文件和demo.js (jquery code)。但它只是行不通。请帮忙。 -
抱歉,没有看到这是 Plunker 链接。问题应直接包含相关部分,而不仅仅是链接到其他网站。
-
但是在没有错误的情况下如何提供零件。只有动画不起作用。此外
demo.js包含jquery part所以我认为应该有一些问题。但不确定。
标签: javascript html css animation angular