I have a div with x images in it aligned horizontally. The div is only showing one image at a time. When I press a button I want to animate the items until the next image is visible. I tried using animation triggers but since I could have unknown number of images I don't know how to change the translate variable within the trigger. When I set state to 'in' it animates once to -100% but I want it to continue to animate to the next image when I click the button again. So for the third image I would need to change the translateX to -200%.
Is there a way to do it, or another way to handle this kind of animation?
trigger('animateX', [
state('in', style({ transform: 'translateX(-100%)' })),
transition('start => in', [
style({
transform: 'translateX(0%)'
}),
animate('0.2s ease-in')
])
])
The template....
<div class="carousel">
<ul class="images">
<li [#animateX]="state">
<img src="myImage1" />
</li>
<li [#animateX]="state">
<img src="myImage2" />
</li>
<li [#animateX]="state">
<img src="myImage3" />
</li>
<ul >
[UPDATE] I would like to add a forward and back buttons which animate the carousel into the corresponding direction. So far I have the following trigger and it works ok except for two cases:
If I press next and then I press the back button the new item appears correctly but the current item leaves into the wrong direction. If I press back again then it is ok. It's only when switching the states from next to prev and vice versa.
When showing the carousel initially I don't want any animation to occur. The carousel should simply show the first item.
Here is the trigger code and below it a plunkr from #micronyks
trigger('animateX', [
state('next', style({})),
transition('* => next', [
style({ transform: 'translatex(100%)' }),
animate(300)
]),
transition('next => void', [
animate(300, style({ transform: 'translateX(-100%)' }))
]),
state('prev', style({})),
transition('* => prev', [
style({ transform: 'translatex(-100%)' }),
animate(300)
]),
transition('prev => void', [
animate(300, style({ transform: 'translateX(100%)' }))
])
])
http://plnkr.co/edit/SS3nb7bkl3YBMoViDsRz?p=preview
Related
How can I add a font awsome animated icon ( like fa fa-reload fa-spin) inside an input using $this->form->input(code)
<div class="input-wrapper">
<input id="stuff">
<label id ="spin" for="stuff" class="fa fa-spinner fa-spin input-icon">
</label>
</div>
and for css
.input-icon{ position: relative; right: 20px; }
input{ padding-right: 20px; }
.input-wrapper{ position: relative; }
I don't know if what you're trying to do it's right from a css point of view
Don't even know if it is the right way to use fontAwesome (You're applying the fa classes to the label instead o using in a <i> as usually done)
So I'm just going to show you how to replicate your exact html using cakephp
if you want to do using just one command you have to leverage on templates. You can change the form templates just for one form, for your whole application or just for a single control.
In my exhample I'm changing the templates just for this control
echo $this->form->control(
'my_input_name',
[
'label' => [
'text' => '',
'id' => 'spin',
'class' => "fa fa-spinner fa-spin input-icon"
],
'templates' => [
'inputContainer' => '<div class="input-wrapper">{{content}}</div>',
'formGroup' => '{{input}}{{label}}',
]
]
)
I want to animate in and out my components when the active router link changes. How do I write the code the animation code so that when the router changes, a component fades out then another fades in?
The code that I've been trying is the following.
#Component({
selector: 'app-component',
templateUrl: './component.component.html',
animations: [trigger(
'openClose',
[
transition(":enter", [
style({ opacity: 0 }),
animate('2000ms', style({ opacity: 1 }))
]),
transition(":leave", [
animate('2000ms', style({ opacity: 0 }))
])
])]
})
But I think I got the concept wrong, as I'm trying to use that piece of code in at least 2 components but none of them is fading in or out.
Is this possible to do with this function or am i tackling the issue with a wrong manner?
Example with Angular 4
Here's how I implemented a fade in animation on my home component route
import { Component } from '#angular/core';
import { fadeInAnimation } from '../_animations/index';
#Component({
moduleId: module.id.toString(),
templateUrl: 'home.component.html',
animations: [fadeInAnimation],
host: { '[#fadeInAnimation]': '' }
})
export class HomeComponent {
}
This is the animation defined in a separate file
import { trigger, state, animate, transition, style } from '#angular/animations';
export const fadeInAnimation =
trigger('fadeInAnimation', [
// route 'enter' transition
transition(':enter', [
// styles at start of transition
style({ opacity: 0 }),
// animation and styles at end of transition
animate('.3s', style({ opacity: 1 }))
]),
]);
For other animations and a live demo you can check out this post
Your code seems correct to me, you just need to bind the animation to a component. There are two ways:
Add it to your template, for example to a div:
<div class="container" [#openClose]="'true'">
...
</div>
Or directly apply it to your host component (<app-component>):
#Component({
selector: 'app-component',
templateUrl: './component.component.html',
animations: [trigger(
'openClose',
[
transition(":enter", [
style({ opacity: 0 }),
animate('2000ms', style({ opacity: 1 }))
]),
transition(":leave", [
animate('2000ms', style({ opacity: 0 }))
])
])],
host: {
'[#openClose]': 'true',
'style': 'display: block;'
},
})
The animation works by component, so you need to declare the animation on both of them.
The leave animation may not be noticed on state change. The official documentation has an example on how to use animations in route components
Hope it helps!
I am using ExtJS 4.2.3
I need a panel to collapse with an animation with a left and right direction.
there are 2 panels the reside in an hbox container.
here is how I am calling the collapse
var me = this,
direction = NG.isRTL() ? Ext.Component.DIRECTION_LEFT : Ext.Component.DIRECTION_RIGHT;
me.collapse(direction);
No matter what I pass for the direction field I alweys get the animation working from right to left. (I need it the other way around)
I have searched the web for it but no one seems to talk about it.
Please see the image I have attached where I have captured the animation half way through.
UPDATE:
Here is a fiddle to demonstrate what I am talking about:
example
It looks like there could be a bug, see https://fiddle.sencha.com/#fiddle/j4p. However, if you want collapsible panels on the right side to collapse to the right, you should just use a border layout. See https://fiddle.sencha.com/#fiddle/j4q
Ext.create('Ext.panel.Panel', {
width: 500,
height: 200,
title: 'Border Layout',
layout: 'border',
items: [{
title: 'South Region is resizable',
region: 'south',
height: 75,
split: true
},{
title: 'East Region is collapsible',
region:'east',
width: 100,
collapsible: true,
},{
title: 'West Region is collapsible',
region:'west',
width: 100,
collapsible: true,
},{
title: 'Center Region',
region: 'center', // center region is required, no width/height specified
xtype: 'panel'
}],
renderTo: Ext.getBody()
});
<link href="http://docs-origin.sencha.com/extjs/4.2.2/styles-3eba09980fa05ead185cb17d9c0deb0f.css" rel="stylesheet"/>
<link href="http://docs-origin.sencha.com/extjs/4.2.2/resources/css/app-4689d2a5522dcd3c9e9923ca59c33f27.css" rel="stylesheet"/>
<script src="http://docs-origin.sencha.com/extjs/4.2.2/extjs/ext-all.js"></script>
inside a gridview i have a css based inline graph. everything is working fine untill i filter something and the gridview gets updated. then css is not registering inside the grid anymore. anyone knows a solution? to be honest i don't even know what to try in this situation. css is not one of my strong points.
this is the element before ajaxupdate:
This is after the ajax update
.stat-block .stat-graph {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #D7D7D7;
border-radius: 3px;
margin-right: 10px;
padding: 10px 10px 8px;
text-align: center;
width: auto;
}
as far as i can see first time the grid is generated css generates a canvas tag like so
<canvas style="display: inline-block; width: 29px; height: 20px; vertical-align: top;" width="29" height="20"></canvas>
but after the ajax update and the refresh of the gridview that tag won't appear anymore.
i have tried to put the graph data inside the canvas tag whit no success.
here is the gridview code:
this->widget('zii.widgets.grid.CGridView', array(
'id' => 'cartuse-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'afterAjaxUpdate' => 'reinstallDatePicker',
'columns' => array(
array(
'id' => 'autoId',
'class' => 'CCheckBoxColumn',
'selectableRows' => '50',
),
// 'id',
array(
'name'=>'client',
'type'=>'raw',
'value'=>'client($data->client)',
'htmlOptions' => array(
'align'=>'center',
//'width'=>'35%'
)
here is the client function:
function client($client) {
...
return '<div class="stat-block" id="graph">
<ul>
<li class="stat-graph inlinebar" id="activitate-lunara">
'.$data.'
</li>
<li class="stat-count">
<span>'.$data['0'].'
</span>
</li>
<li class="stat-percent">
<span class="text-info stat-percent">'.$target.'</span>
</li>
</ul>
</div>';
}
Edit 1 :
as recomended in answer 1 i used the removeClass() and addClass() functions to refresh css after ajax update. nothing hapens, the canvas tag still won't appear.
i tryed to use replaceWith() and just insert the canvas tag that way but then it will brake the filtering.
here's the reinstallDatePicker function
<?php Yii::app()->clientScript->registerScript('re-install-date-picker', "
function reinstallDatePicker(id, data) {
$('#datepicker_min').datepicker({ dateFormat: 'yy-mm-dd',
showOtherMonths: true,
selectOtherMonths: true,
changeYear: true,
changeMonth: true,
});
$('#datepicker_max').datepicker({ dateFormat: 'yy-mm-dd',
showOtherMonths: true,
selectOtherMonths: true,
changeYear: true,
changeMonth: true,
});
$( \"#activitate-lunara\" ).removeClass( \"stat-graph inlinebar\" );
$( \"#graph\" ).removeClass( \"stat-block\" );
$( \"#graph\" ).addClass( \"stat-block\" );
$( \"#activitate-lunara\" ).addClass( \"stat-graph inlinebar\" );
}"); ?>
Edit 2:
i wasn't using renderPartial as column content. just a function that returned the content i wanted. after exhausting All posible ideeas i moved to renderpartial and with renderpartial + registering scripts / css in the partialview and removeclass / addclass everything is working fine now.
I have this issue sometimes as well.
First thing: If you're using partial views, include the CSS in the partial view as well.
If not, you will probably have to re-apply the style after each ajax update.
I see that you are using "afterAjaxUpdate"=>"reinstallDatePicker" so one way to fix your problem is to add that CSS to .stat-block .stat-graph inside that function. You can use jquery functions like css(), addClass() and many others.
But the important thing is that you style your elements after each ajax update. Since your function reinstallDatePicker is being called after each ajax update, you can just add some code to this function to do what you want (that is, re-style the elements).
i have tried everything i can think of without success. the only way i could get it to work was to store my filter data in my session and then afterajaxupdate force a reload. (not really recommended because if your query's are not optimized i guess it could slow down your page)
i'm just posting this here in case someone else has this problem and want to get it working before someone else finds a correct solution
so now in my controller i have this
public function actionAdmin()
{
$model=new Cartuse('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Cartuse']))
$_SESSION['filterData'][$this->id][$this->action->id] = $_GET['Cartuse'];
$model->attributes=$_SESSION['filterData'][$this->id][$this->action->id];
if (isset($_GET['pageSize'])) {
Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
unset($_GET['pageSize']);
}
$this->render('admin',array(
'model'=>$model,
));
}
and in my gridview
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'cartuse-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'afterAjaxUpdate' => 'reinstallDatePicker',
'columns' => array(/*
.....
)
));
and the reinstall datepicker (for some reason if i put the location.reload () directly in the afterajaxupdate field my datepickers won't register (not even first time) and filtering stops working. so i put it in the reinstalldatepicker function. no problems till now.
<?php Yii::app()->clientScript->registerScript('re-install-date-picker', "
function reinstallDatePicker(id, data) {
location.reload();
$('#datepicker_min').datepicker({ dateFormat: 'yy-mm-dd',
showOtherMonths: true,
selectOtherMonths: true,
changeYear: true,
changeMonth: true,
});
$('#datepicker_max').datepicker({ dateFormat: 'yy-mm-dd',
showOtherMonths: true,
selectOtherMonths: true,
changeYear: true,
changeMonth: true,
});
$.datepicker.setDefaults($.datepicker.regional['ro']);
}
");
this is not really a solution, its jut a cheap workaround so if anyone has a solution i'll be waiting for it.
actually i am not a programmer, i am a designer...many than for those who reply this case.....
i have difficulties applying show and hide content on flip plugin.....
var init = function(){
$("#flipTop").click(function(e){
$("#flipbox").flip({
dir: "top",
endColor: "white",
duration:777,
onEnd: function(){
$("#flipbox").html(TOP);
$("#flipbox").css();
}
});
});
$("#flipRight").click(function(e){
$("#flipbox").flip({
dir: "right",
endColor: "yellow",
duration:777,
onEnd: function(){
$("#flipbox").html("RIGHT");
$("#flipbox").css({
color: "red",
background: "yellow"
});
}
});
});
$("#flipLeft").click(function(e){
$("#flipbox").flip({
dir: "left",
endColor: "blue",
duration:777,
onEnd: function(){
$("#flipbox").html("LEFT");
$("#flipbox").css({
color: "white",
background: "blue"
});
}
});
});
$("#flipBottom").click(function(e){
$("#flipbox").flip({
dir: "bottom",
endColor: "red",
duration:777,
onEnd: function(){
$("#flipbox").html("BOTTOM");
$("#flipbox").css({
color: "yellow",
background: "red"
});
}
});
});
}
$(document).ready(init);
===================================================================================================
I thought the above javascript is too redundant...it must be simplified in order to change show and hide content selected
and here is the HTML i tried to make.......
<ul id="navigation" >
<li class="selected">
TOP </li>
<li> RIGHT </li>
<li> LEFT </li>
<li> BOTTOM </li>
</ul>
<div id="container">
<div id="flipbox" class="top">
TOP
</div>
<div id="flipbox"class="right">
RIGHT
</div>
<div id="flipbox"class="left">
LEFT
</div>
<div id="flipbox"class="bottom">
BOTTOM
</div>
</div>
==========================================================================================
then i try to compile this for the java script command but i didnt work.... :(
$('document').ready(function(){
$('#flipbox').flip();
$('#navigation li a').each(function(){
$(this).click(function(){
$('#navigation li').each(function(){
$(this).removeClass('selected');
});
$(this).parent().addClass('selected');
var flipid=$(this).attr('id').substr(4);
$('#flipbox').flip({
dir: $this.attr("id"),
endColor: $this.attr("rel"),
duration:$this.attr("rev"),
onEnd: function(){
}, flipid, 1);
return false;
});
});
});
what i want to ask is how to make those works show and hide content after flip effect while clicking on the tab navigation......thanks a lot for those response this problemmmm
View the source-code of this page http://lab.smashup.it/flip/ it might help you understand, as i have never tried flip plugin yet i am willing to help you.!!