I need to delete default navigation (nextEl, prevEl) and make button with "NEXT SLIDE BUTTON" text scroll to next slide
<swiper class="news-slider" :sliderd-per-view="1" :modules="[Navigation, Pagination, A11y, Lazy]" navigation="navigation" :navigation="{ nextEl: '.nextArrow'}" :pagination="{ clickable: true, dynamicBullets: true, dynamicMainBullets: 5 }" preload-images="false" lazy="lazy">
<swiperSlide class="swiper-slide" v-for="n in 10" :key="n">
<div class="news-container">
<div class="news"><img class="news__image swiper-lazy" src="#/assets/img/lookism-transformed-transformed.png" alt=""/>
<div class="swiper-lazy-preloader"></div>
<div class="news__info">
<div class="news__title">title</div>
<div class="news__description">description</div>
<div class="news__buttons">
<button class="normal-button news-button">more</button>
<button class="next-button"><span class="next-button__text">NEXT SLIDE BUTTON</span><img class="next-button__icon" src="#/assets/img/arrow-right.svg" alt=""/></button>
</div>
</div>
</div>
</div>
</swiperSlide>
</swiper>
<script>
export default {
components: {
Swiper,
SwiperSlide,
},
setup() {
const onSwiper = (swiper) => {
console.log(swiper);
};
const onSlideChange = () => {
console.log('slide change');
};
return {
onSwiper,
onSlideChange,
modules: [Navigation, Pagination, Scrollbar, A11y],
};
},
};
</script>
How can i do that? I will be very grateful for your help
This should do it, all you need to do is import useSwiper and assign it to a const variable and use it in the div element as swiper.slideNext()
And also if you do not wish to use swiper's own elements then remove the navigation module.
Here's the doc source which is clearer
https://swiperjs.com/vue#use-swiper
Related
I have a div that looks like this:
<div id="data" class="grid grid-cols-2">
</div>
and I have a function that can append in data div:
function loadStaticBar(data) {
let pl_name= `bar-${data.title.replace(/\s+/g, '-').toLowerCase()}`
$('#data').append(`
<div class="flex flex-col" id="${pl_name}-wrapper">
<div class="static barchart" id="${pl_name}-plot">
</div>
</div>
`)
}
The content of loadStaticBar(data) is a key and value it's a details for charts:
{id: 453, title: 'Bar Chart Example', select: 'bar-form', xtitle: 'Values', ytitle: 'Date', …}
Now, I'm trying to get all the IDs with the class static. I have tried:
$('#data').find('.static')
And I get S.fn.init [prevObject: S.fn.init(1)] inside of this are bunch of information. How can I get the IDs of the div that containing static class like this.
ids = [line-plot, bar-plot]
The answer to the updated question could be:
function loadStaticBar(data) {
let pl_name= `bar-${data.title.replace(/\s+/g, '-').toLowerCase()}`
$('#data').append(`
<div class="flex flex-col" id="${pl_name}-wrapper">
<div class="static barchart" id="${pl_name}-plot">
</div>
</div>
`)
}
const data={id: 453, title: 'Bar Chart Example', select: 'bar-form', xtitle: 'Values', ytitle: 'Date'};
$(function(){
loadStaticBar(data); // create the divs first !!!
const ids=$("#data .static").get().map(el=>el.id);
console.log(ids);
});
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<div id="data" class="grid grid-cols-2">
</div>
As you want to receive a "proper" array instead of a jQuery object it makes sense to .get() the selected DOM elements first and then .map() them using the standard Array-method.
Incidentally, you can solve the originally posted question also without jQuery:
document.addEventListener("DOMContentLoaded", function () {
const ids=[...document.querySelectorAll("#data .static")].map(el=>el.id);
console.log(ids);
});
<div id="data" class="grid grid-cols-2">
<div class="flex flex-col" id="line-wrapper">
<div class="static linechart" id="line-plot">
</div>
</div>
<div class="flex flex-col" id="bar-wrapper">
<div class="static barchart" id="bar-plot">
</div>
</div>
</div>
I need to display both swiper (https://www.npmjs.com/package/swiper) and cdkDrag (https://material.angular.io/cdk/drag-drop/overview) functions for a group of elements.
The problem is that when I use the swiper, cdkDrag stops working.
Maybe I am doing something wrong, or the swiper does not support cdkDrag.
Here is my code html :
landing.component.html
<!-- Swiper -->
<div [hidden]="appListService?.normalAppList?.length <= 0" class="bg-white landing-apps-footer">
<div class="landing-apps-container">
<swiper [config]="config" (click)="onPaginationClick($event)" #usefulSwiper>
<div id="landing-apps-detail-list" class="fh swiper-wrapper app-list" cdkDropList draggable="true"
(cdkDropListDropped)="drop($event)" [cdkDropListData]="appListService.normalAppList"
[cdkDropListConnectedTo]="firstList" #secondList="cdkDropList" cdkDropListOrientation="horizontal">
<div class="swiper-slide pop" *ngFor="let dataItem of appListService.normalAppList" cdkDrag (cdkDragStarted)="onDragStarted()">
<a class="apps {{dataItem.icon}}" (click)="gotoAppPage(dataItem)" draggable="false"
style="cursor: pointer;">
<span class="icon"></span>
<span class="title"
id="landing-detailApp{{ dataItem.appCode }}">{{ dataItem.appName }}</span>
</a>
</div>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-next" id="landing-btnNext"></div>
<div class="swiper-button-prev"></div>
</swiper>
</div>
</div>
Here is my code typescript :
config: SwiperOptions = {
pagination: { el: '.swiper-pagination', clickable: true },
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
spaceBetween: 30,
loop: false,
loopFillGroupWithBlank: false, //hide/show virtual items
initialSlide: 0, // Slide Index Starting from 0
slidesPerView: 6, // Slides Visible in Single View Default is 1
slidesPerGroup: 6,
on: {
init: function () {
console.log('swiper initialized');
},
slideChange: function () {
console.log('swiper slideChange');
},
touchMove: function () {
console.log('swiper Move');
},
tap: function () {
console.log('tap');
},
touchStart: function () {
console.log('touchStart');
},
},
};
Please let me know if anyone has encountered a similar problem and was able to configure cdkDrag support (https://material.angular.io/cdk/drag-drop/overview) for swiper (https://www.npmjs.com/package/swiper) in Angular 2+
Here I ave written a vue.js code. Here I have tried to achieve to toggle a div. if i will click a button "deals of the day" then I am toggling a other div. similarly I am doing with all other three divs. And it is working fine but i want to enhance this functionality like if user clicks on one button then div will toggle then similarly if user clicks on other button to toggle a div then previously toggle div should automatically close how to achieve this in vue.js
<script>
new Vue({
el: '#category_app',
data () {
return {
toggle: false,
latestClassifieds: false,
latestcomments: false,
}
},
})
</script>
<div>
<div>
<div #click='toggletwo = !toggletwo' class="dealOfDay">Deal of the day</div>
<div v-show='toggletwo' class="DayListings">Deals of the day Listings</div>
</div>
<div>
<div #click='latestClassifieds = !latestClassifieds' class="dealOfDay">Advertiser</div>
<div v-show='latestClassifieds'>Advertise listings</div>
</div>
<div>
<div #click='latestcomments = !latestcomments' class="dealOfDay">Latest Classifieds</div>
<div v-show='latestcomments'>Latest classified listings</div>
</div>
</div>
A quick solution could be:
<script>
new Vue({
el: '#category_app',
data () {
return {
toggle: 1
}
}
})
</script>
<div>
<div>
<div #click='toggle = 1' class="dealOfDay">Deal of the day</div>
<div v-show='toggle === 1' class="DayListings">Deals of the day Listings</div>
</div>
<div>
<div #click='toggle = 2' class="dealOfDay">Advertiser</div>
<div v-show='toggle === 2'>Advertise listings</div>
</div>
<div>
<div #click='toggle = 3' class="dealOfDay">Latest Classifieds</div>
<div v-show='toggle === 3'>Latest classified listings</div>
</div>
</div>
You can set toggle variable to 0 by default if you don't want to have any of them open after page is loaded.
Hi people, I am using Semantic UI React for my project. Here I am rendering some content on a Modal. Here you search for the movies and click on add and it adds it below. The problem is that I want the movie list to be aligned with the start of the Search bar. I'm not able to do it. Is there any way using Grid that I can achieve it?
Here is my code:
import React, {useState, useEffect} from 'react';
import {Icon, Button, Modal, Input, Item} from 'semantic-ui-react'
const CreateMovieListModal = (props) => {
const [movieTitle, setMovieTitle] = useState('');
const [movieList, setMovieList] = useState([]);
function handleMovieChange (event, data) {
setMovieTitle(data.value);
}
function addMovie () {
const newMovies = [...movieList, movieTitle];
setMovieList(newMovies);
setMovieTitle('');
}
function showMovieList () {
return movieList.map((currentMovie)=> {
return (
<Item.Group>
<Item>
<Item.Image size='tiny' src='https://react.semantic-ui.com/images/wireframe/image.png' />
<Item.Content verticalAlign='middle'>
<Item.Header as='a'>{currentMovie}</Item.Header>
</Item.Content>
</Item>
</Item.Group>
)
})
}
return (
<Modal open={props.isOpen} onClose={props.onClose}>
<Modal.Header>Add a new list</Modal.Header>
<div style={{marginTop: '10px'}}>
<center>
<Input value={movieTitle} loading={false}
style={{width: '50%'}}
onChange={handleMovieChange}
placeholder='Search For Movies'
/>
<Button onClick={addMovie}>Add Movie</Button>
</center>
</div>
<Modal.Content scrolling>
<div>
{showMovieList()}
</div>
</Modal.Content>
<Modal.Actions>
<Button primary>
Save <Icon name='save' />
</Button>
</Modal.Actions>
</Modal>
);
};
export default CreateMovieListModal;
you need to wrap Input and Movie list into a div, and apply your <center> on that wrapper div:
<center>
<div> <!-- wrapper div -->
<Input value={movieTitle} loading={false}
style={{width: '50%'}}
onChange={handleMovieChange}
placeholder='Search For Movies'
/>
<Button onClick={addMovie}>Add Movie</Button>
<Modal.Content scrolling>
<div>
{showMovieList()}
</div>
</Modal.Content>
</div>
</center>
This is what i'm trying to achieve.
section1 will be hidden at page load. When user clicks on Advanced, section1 should show & section2 should hide. On clicking Basic, the opposite should happen. Nothing happens when I click any of the anchor tags now. Where am i going wrong.
<div class="container" ng-init="advstatus=true">
Basic
<br/>
Advanced
<div class="section1" ng-hide="advstatus">
///...
</div>
<section ng-show="advstatus" class="section2">
///...
</section>
</div>
In AngularJS you need to use ng-click instead of onclick.
Also, ng-init isn't supposed to be used unless you're in ng-repeat, which you are not (take a look at the Docs).
You should set up the variable in your controller:
<div ng-app ng-controller="myCtrl" class="container" >
Basic
<br/>
Advanced
<div class="section1" ng-show="!advstatus">
Section 1
</div>
<section ng-show="advstatus" class="section2">
Section 2
</section>
</div>
Controller:
function myCtrl($scope) {
$scope.advstatus = true;
}
JS Fiddle
This one is easy to understand
<div class="section1" ng-show="state1">
Section 1
</div>
<div class="section2" ng-show="state2">
Section 2
</div>
<input type="button" value="Advance" ng-click="sec1_show()" />
<input type="button" value="Basic" ng-click="sec2_show()" />
<script>
function homecntrl($scope) {
$scope.state1 = false;
$scope.state2 = true;
$scope.sec1_show = function () {
$scope.state1 = true;
$scope.state2 = false;
};
$scope.sec2_show = function () {
$scope.state2 = true;
$scope.state1 = false
};
};
</script>
Very simple just do this:
<button ng-click="hideShow=(hideShow ? false : true)">Toggle</button>
<div ng-if="hideShow">hide and show content ...</div>