Vue3 transition-group not working as expected - html

I am new to Vue in general and working on a project with a carousel that will show the different images fine, but the transition is not working as expected. Each time a new image shows, the transition has some style that has it go from the bottom left corner to the center. Any suggestions on how to make it slide like a carousel similar to https://www.jssor.com/demos/full-width-slider.slider without the buttons on the sides?
I know that when my images change that the .fade-move css class gets applied, but I can't find the right combo to make the current slide go out left and bring the next slide in from the right. If I add the styling to all div's div {transition: all 2s ease);}, then it will "transition", but I can't figure out why it's starting from the bottom right corner.
<script setup lang="ts">
let slides = ref(
[
{
url: x.svg,
title: "test 1",
id: 0,
},
{
url: y.svg,
title: "test 2",
id: 1,
},
{
url: z.svg,
title: "test 3",
id: 2,
},
]
);
let GREENCIRCLE = green.svg;
let WHITECIRCLE = white.svg;
let active = ref(0);
function next () {
active.value = (active.value + 1) % slides.value.length
}
onMounted(() => {
window.setInterval(next,4000);
})
</script>
<template>
<div class='carousel-view'>
<transition-group
class='carousel'
tag="div"
name="fade">
<div class="slide-container"
v-for="slide, idx in slides"
:key="slide.id"
>
<div
class='slide'
v-if="idx===active">
<img :src="slide.url" />
<h3> {{ slide.title }} </h3>
</div>
</div>
</transition-group>
<div class="links-container">
<a class="carousel-links"
#click="active=idx"
v-for="slide, idx in slides"
:key="slide.id">
<img
class="carousel-controls"
:src="idx === active ? GREENCIRCLE : WHITECIRCLE"
/>
</a>
</div>
</div>
</template>
<style scoped>
/* carousel effect */
div {
transition: all 2s ease;
}
.fade-move {
transform: translateX(100%);
transition: transform 3s ease-in-out;
}
</style>

Related

How to incorporate progress bar in vertical form step with validation

I have used the Vertical Form Step from the below Jquery steps
http://www.jquery-steps.com/Examples
It's working fine. Now I want to show the progress bar with validation when I click the next button without bootstrap.
Can anyone please help to make this?
The code I have done so far,
$("#example-vertical").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="example-vertical">
<h3>Keyboard</h3>
<div id="myProgress">
<div id="myBar">50%</div>
</div>
<section>
<p>Try the keyboard navigation by clicking arrow left or right!</p>
</section>
<h3>Effects</h3>
<section>
<p>Wonderful transition effects.</p>
</section>
<h3>Pager</h3>
<section>
<p>The next and previous buttons help you to navigate through your content.</p>
</section>
</div>
Check now
var currentIndex;
var steps;
var wizardLength = $("#example-vertical").find('h3').length;
$("#example-vertical").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical",
startIndex: 0,
currentIndex:1,
onInit:function (event, currentIndex) {
setProgressBar(currentIndex);
},
onStepChanged: function (event, currentIndex, priorIndex) {
setProgressBar(currentIndex);
//console.log(currentIndex);
//console.log(wizardLength);
},
});
// Change progress bar action
function setProgressBar(currentIndex) {
var percent = parseFloat(100 / wizardLength) * (currentIndex + 1);
percent = percent.toFixed();
$(".progress-bar")
.css("width", percent + "%")
.html(percent + "%");
}
#myProgress{
background: #eee;
}
.progress-bar{
background: green;
color: #fff;
text-align: center;
}
<link href="http://www.jquery-steps.com/Content/Examples.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-steps/1.1.0/jquery.steps.min.js"></script>
<div id="example-vertical">
<h3>Keyboard</h3>
<div id="myProgress">
<div id="myBar" class="progress-bar">50%</div>
</div>
<section>
<p>Try the keyboard navigation by clicking arrow left or right!</p>
</section>
<h3>Effects</h3>
<section>
<p>Wonderful transition effects.</p>
</section>
<h3>Pager</h3>
<section>
<p>The next and previous buttons help you to navigate through your content.</p>
</section>
</div>

Swiper.js not able to render the 'Apex-Chart'-Series when swipe between (first to last) or (last to first) slide

I'm facing an unknown issue only when I'm swiping between last (swiper-slide) to first (swiper-slide) and same as first to last, but when I do just a half swipe, then the RedialBar looks good.
I set the loop: true. I have 3 Slides. Inside all Slide, i have a very simple APEX RadialBar/Circle Chart's. Everything works nice. But when I slide 1 to 2 Good. 2 to 3 Good. But when I slide 3 to 1 then the RadialBar series does not render. And same problem when I slide 1 to 3. So if I just do a half slide (just a little swipe), then the RadialBar render perfectly.
$(document).ready(function () {
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'horizontal',
loop: true,
pagination: {
el: '.swiper-pagination',
type: 'bullets',
clickable: true
},
effect: 'slide'
})
mySwiper.on('slideChange', function () {
console.log('slide changed');
});
});
// Apex Chart
let options = {
series: [50],
chart: {
height: 200,
type: 'radialBar',
},
plotOptions: {
radialBar: {
hollow: {
size: '70%',
}
},
},
stroke: {
lineCap: 'round'
},
labels: ['Country'],
};
let chart = new ApexCharts(
document.querySelector("#demo-chart-1"),options
);
let chart2 = new ApexCharts(
document.querySelector("#demo-chart-2"),options
);
let chart3 = new ApexCharts(
document.querySelector("#demo-chart-3"),options
);
chart.render();
chart2.render();
chart3.render();
body {
background-color: #a3d5d3;
}
.india,
.canada,
.japan {
height: 100;
border: 1px solid green;
display: grid;
place-items: center;
}
<script src="https://unpkg.com/swiper/js/swiper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<link href="https://unpkg.com/swiper/css/swiper.min.css" rel="stylesheet"/>
<div class="swiper-container">
<div class="swiper-wrapper">
<!-- Slide 1-->
<div class="swiper-slide">
<section class="india">
<p class="gas-header">INDIA</p>
<div id="demo-chart-1"></div>
</section>
</div>
<!-- Slide 2-->
<div class="swiper-slide">
<section class="canada">
<p class="gas-header">CANADA</p>
<div id="demo-chart-2"></div>
</section>
</div>
<!-- Slide 3-->
<div class="swiper-slide">
<section class="japan">
<p class="gas-header">JAPAN</p>
<div id="demo-chart-3"></div>
</section>
</div>
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>
</div>

Angularjs - How to collapse and expand the accordion slowly with animation

I am using angularjs and having a simple accordion with expand and collapse,Every thing is working fine but here when I expand the div it should expand slowly and similarly when I collapse again it should collapse slowly.Here I am using isopen for expand in angularjs.Anyone can help me,Below is my code,https://plnkr.co/edit/nCdGzZYPSTYsMPYf8K9o?p=preview
HTML
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.1/angular.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.1/angular-sanitize.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.js'></script>
<script src="js/index.js"></script>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css'>
<body ng-app="app">
<h1>Dynamic accordion: nested lists with html markup</h1>
<div ng-controller="AccordionDemoCtrl">
<div>
<div ng-repeat="group in groups track by $index">
<div class="parents" ng-click="open($index)"><i ng-class="{'glyphicon-minus': group.isOpen, 'glyphicon-plus': !group.isOpen}"></i> {{ group.title }}
</div>
<div class="childs" ng-show="group.isOpen">ddddd</div>
</div>
</div>
</div>
</body>
index.js
var app=angular.module('app', ['ui.bootstrap','ngSanitize','angular.filter']);
app.controller('AccordionDemoCtrl', function ($scope) {
$scope.oneAtATime = true;
$scope.open = function (index) {
$scope.groups[index].isOpen = !$scope.groups[index].isOpen;
$scope.closeOthers(index);
}
$scope.closeOthers = function (index) {
for(var i = 0; i < $scope.groups.length; i++) {
if (i !== index)
$scope.groups[i].isOpen = false;
}
}
$scope.groups = [
{
title: 'title 1',
list: ['<i>item1a</i> blah blah',
'item2a',
'item3a']
},
{
title: 'title 2',
list: ['item1b',
'<b>item2b </b> blah ',
'item3b']
},
{
title: 'title 3',
},
{
title: 'title 4',
},
{
title: 'title 5',
}
];
$scope.groups[0].isOpen = true;
});
You can use css max-height and add transition to make collapse and expand slowly
.childs {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease-out;
}
.childs.showChild {
max-height: 1000px;
}
<ul class="childs" ng-class="{'showChild': group.isOpen}">
<li ng-repeat="item in group.list">
<span ng-bind-html="item"></span>
</li>
</ul>
See the demo
https://plnkr.co/edit/Gm7oe8l3ZBXyWTe3Okm4?p=preview

How to set Image Slider

var Home = React.createClass({
render: function() {
return (
<div>
<img src="images/12.jpg" />
<img src="images/11.jpg" />
<img src="images/13.jpg" />
<img src="images/14.jpg" />
</div>
)
}
})
I need these 4 images as a slider can anyone give me the code using react or html with CSS
Use ready-made library, here example
https://github.com/jossmac/react-images
https://github.com/xiaolin/react-image-gallery
http://kenwheeler.github.io/slick/
First that is not the way to ask a question. Check here how to ask good question.
You can use some of all made React Slider Components, but if you want to do it on your own you can do something like this :
This is only to get the idea :
class Test extends React.Component {
constructor(){
super();
this.state = {
marginLeft: 0
}
}
componentDidMount(){
this.interval = setInterval(this.changeSlide.bind(this), 2000);
}
changeSlide(){
let totalSlides = document.getElementById("inner").children.length - 1;
let getWidth = document.getElementById("slide1").offsetWidth;
let marginLeft = this.state.marginLeft;
if((totalSlides * -getWidth) >= this.state.marginLeft){
marginLeft = 0
}else{
marginLeft = this.state.marginLeft - getWidth
}
this.setState({marginLeft})
}
render(){
return (
<div className="outter">
<div id="inner" className="inner" style={{marginLeft: this.state.marginLeft}}>
<img src="https://cdn.pixabay.com/photo/2016/12/29/16/12/eiskristalle-1938842_960_720.jpg" style={{maxWidth: "100%"}} id="slide1"/>
<img src="https://cdn.pixabay.com/photo/2014/10/16/09/15/frost-490807_960_720.jpg" style={{maxWidth: "100%"}} id="slide2"/>
<img src="https://cdn.pixabay.com/photo/2015/03/01/07/24/winter-654442_960_720.jpg" id="slide3"/>
</div>
</div>
)
}
}
ReactDOM.render(<Test />, document.getElementById('container'));
.outter{
width: 500px;
overflow: hidden;
}
.inner{
width: 1000%;
float:left;
margin-left: 0;
transition: all 1s ease;
}
.inner img{
max-width: 500px;
width: 500px;
float:left;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
In componentDidMount set interval to call the function to change the slide every 2 seconds (in this case).
In function changeSlide first you need to get total slides and the width of the first one (because all have the same width).
Then if it's the last slide set margin-left to 0 and if it's not then subtract the photo width of the current margin-left in the state. At the end update the state.
Hope that this will give you the idea how you can do it.
Here is the fiddle.

clickable column/bar/horizontal layout with sencha

I have a problem trying to make a column clickable on sencha. I tried various ways, putting the text in a container, component, etc and I cant get it to react to a click.
Here is the code snippet. Check out the listener, it doesnt work when I tap on the text or that layout bar. Please help!
app.views.test = Ext.extend(Ext.Panel, {
scroll: "vertical",
id: 'test',
initComponent: function() {
var testbar = {
layout : {
type : 'vbox',
align : 'start',
pack : 'start'
},
width : '60%',
items : [{
html : 'press this column
bar : '5 0 0 15',
width : '100%'
}],
listeners: {
itemtap : function () {
console.log("goto next");
}
}
};
var testViews = {
items : [ testbar ]
};
this.items = [ testViews ];
app.views.test.superclass.initComponent.apply(this, arguments);
},
onSelect: function(sel, records){
if (records[0] !== undefined) {
}
}
});
As to answer your last comment, no, vbox might be overkill if you do not need most panel's functionalities. I would suggest to just use pure dom. The good thing about pure dom is that it you have your full control over what you need. If you use vbox, you will end up negating or disabling some of the css/functionalities it is providing.
So first, this is pure dom method: link to example
//Create a simple namespace. Habit :)
Ext.ns('NS');
/**
* This is the customized menu component
* Usage: bla bla..
*/
NS.Menu1 = Ext.extend(Ext.Component, {
/**
* #cfg menu
* An array of menu items to be rendered into the component
*/
menu: [],
initComponent: function() {
NS.Menu1.superclass.initComponent.call(this);
//We create our own customized event, so users can hook events onto it
this.addEvents({
/**
* #event menuclick
* Fires when the menu is clicked
* #param {NS.Menu1} cp this component
* #param {Menu} m The menu item
* #param {Ext.Element} a The anchor element
* ... or whatever you want to pass
*/
menuclick: true
});
//We hook an afterrender event here, so we could know
//when will be our el be rendered.
this.on('afterrender', this.onAfterRender, this);
},
onAfterRender: function() {
var me = this;
//Let's do all the fancy stuff here:
Ext.each(me.menu, function(m) {
//el property is always there as long as you subclass
//Ext.Component. It's the outermost div of the component.
//We create multiple single anchors here (of course ul/li/a is better)
var a = me.el.createChild({
tag: 'a', //so we can have :hover supports from crappy IE
html: m.text, //or anything you like
cls: 'item' //and the class to style it
//then we hook 'click' even to this anchor
}).on('click', function() {
//Then do whatever you like here
Ext.get('output1').update(m.text);
//Or even firing your own customized events, whatever you like
me.fireEvent('menuclick', me, m, a);
//or whatsoever...
});
});
}
});
//Finally, testing it out!
new NS.Menu1({
renderTo: 'menu1',
menu: [{
text: 'This is the first menu'
},{
text: 'This is the 2nd menu'
},{
text: 'This is the last menu'
}]
}).on('menuclick', function(cp, m) {
Ext.get('output2').update(m.text);
});
And then, this is the vbox way. Notice how I create them in a single loop: go to example
/**
* This is the column bars with clickable areas
*/
Ext.ns('NS');
NS.Menu2 = Ext.extend(Ext.Panel, {
/**
* #cfg menu
* An array of menu items to be rendered into the component
*/
menu: [],
border: false,
layout: {
type: 'vbox',
align: 'stretch'
},
initComponent: function() {
var me = this;
//Same thing, you can do event hook here:
me.addEvents('menuclick');
me.items = [];
//Create all the boxes as you like
Ext.each(me.menu, function(m) {
me.items.push({
html: m.text,
bodyCssClass: 'item',
bodyStyle: 'padding-bottom: 0px;margin-bottom: 0px;',
listeners: {
afterrender: function(p) {
//As you can see, we hook the afterrender event so
//when your panels (each individual panels) are created,
//we hook the click event of the panel's root el.
p.el.on('click', function() {
Ext.get('output1').update(m.text);
//Fires event
me.fireEvent('menuclick', me, m, p.el);
});
}
}
});
});
NS.Menu2.superclass.initComponent.call(this);
}
});
new NS.Menu2({
renderTo: 'menu2',
height: 300,
menu: [{
text: 'This is the first menu'
},{
text: 'This is the 2nd menu'
},{
text: 'This is the last menu'
}]
}).on('menuclick', function(cp, m) {
Ext.get('output2').update(m.text);
});
Both of them looks similar, just vbox way is a little bit overkilling as it processed a little bit more stuff than using pure dom. Inspect both generated dom nodes to see the differences.
This is the dom nodes generated in example 1:
<div id="ext-comp-1001">
<a class="item" id="ext-gen3">This is the first menu</a>
<a class="item" id="ext-gen4">This is the 2nd menu</a>
<a class="item" id="ext-gen5">This is the last menu</a>
</div>
And this is in example 2:
<div id="ext-comp-1001" class=" x-panel x-panel-noborder">
<div class="x-panel-bwrap" id="ext-gen3">
<div class="x-panel-body x-panel-body-noheader x-panel-body-noborder x-box-layout-ct" id="ext-gen4" style="height: 300px; ">
<div class="x-box-inner" id="ext-gen6" style="width: 836px; height: 300px; ">
<div id="ext-comp-1002" class=" x-panel x-box-item" style="width: 836px; left: 0px; top: 0px; ">
<div class="x-panel-bwrap" id="ext-gen7"><div class="x-panel-body item x-panel-body-noheader" id="ext-gen8" style="padding-bottom: 0px; margin-bottom: 0px; width: 824px; height: 24px; ">This is the first menu</div>
</div>
</div>
<div id="ext-comp-1003" class=" x-panel x-box-item" style="width: 836px; left: 0px; top: 31px; ">
<div class="x-panel-bwrap" id="ext-gen10">
<div class="x-panel-body item x-panel-body-noheader" id="ext-gen11" style="padding-bottom: 0px; margin-bottom: 0px; width: 824px; height: 24px; ">This is the 2nd menu</div>
</div>
</div>
<div id="ext-comp-1004" class=" x-panel x-box-item" style="width: 836px; left: 0px; top: 62px; ">
<div class="x-panel-bwrap" id="ext-gen13">
<div class="x-panel-body item x-panel-body-noheader" id="ext-gen14" style="padding-bottom: 0px; margin-bottom: 0px; width: 824px; height: 24px; ">This is the last menu</div>
</div>
</div>
</div>
</div>
</div>
Get what I mean?